Ejemplo n.º 1
0
void
testExtrudedPgon::matched_g4_and_dd( void )
{
  std::vector<double> x = { -300, -300, 300, 300, 150, 150, -150, -150 };
  std::vector<double> y = { -300, 300, 300, -300, -300, 150, 150, -300 };
  std::vector<double> z = { -600, -150, 100, 600 };
  std::vector<double> zx = { 0, 0, 0, 0 };
  std::vector<double> zy = { 300, -300, 0, 300 }; 
  std::vector<double> zscale = { 8, 10, 6, 12 };
  std::string name( "fred1" );

  std::vector<G4TwoVector> polygon;
  std::vector<G4ExtrudedSolid::ZSection> zsections;
  for( unsigned int it = 0; it < x.size(); ++it )
    polygon.emplace_back( x[it], y[it] );
  for( unsigned int it = 0; it < z.size(); ++it )
    zsections.emplace_back( z[it], G4TwoVector(zx[it], zy[it]), zscale[it] );
  G4ExtrudedSolid g4( name, polygon, zsections );
  DDI::ExtrudedPolygon dd( x, y, z, zx, zy, zscale );
  DDExtrudedPolygon dds = DDSolidFactory::extrudedpolygon( name,  x, y, z, zx, zy, zscale );

  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<<  std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
  
  // FIXME: dd voulme is not implemented yet!
  // CPPUNIT_ASSERT( g4.GetCubicVolume()/cm3 == dd.volume()/cm3 );
}
Ejemplo n.º 2
0
int
main (void)
{
  struct s g6_s = { 106 };

  start (1, 0);
  g1 (tmp);

  start (2, 0);
  g2 (&tmp);

  start (3, 0);
  g3 (&tmp);

  start (4, 0);
  g4 (&tmp);

  start (5, 0);
  g5 (tmp);

  start (6, &g6_s);
  g6 (tmp);

  start (7, 0);
  g7 (tmp);

  start (8, 0);
  g8 (&tmp);

  start (9, 0);
  g9 (&tmp);

  return 0;
}
Ejemplo n.º 3
0
bool sanity()
{  
   GameState g0(5, 7, 7);    // Not a valid game state 
   GameState g1(1, 2, 254);  // Finish in 1 round
   GameState g2(2, 3, 254);  //   ...  in 2 rounds
   GameState g3(3, 4, 254);  //   ...  in 3 rounds
   GameState g4(4, 5, 254);  //
   GameState g5(4, 9, 254);  // These come from a (slower) python implementation
   GameState g6(8, 11, 254);
   GameState g7(12, 19, 254);
   GameState g8(8, 35, 254);
   
   GameState g9(1, 4, 6);   // From webpage, known to finish in 15 minutes = at round 2
   
   if (explore_game(g0)!=0) return false; // Verify that we get the expected number
   if (explore_game(g1)!=1) return false; // of rounds for given input states
   if (explore_game(g2)!=2) return false; //
   if (explore_game(g3)!=3) return false; // report an error if not
   if (explore_game(g4)!=4) return false;
   if (explore_game(g5)!=5) return false;
   if (explore_game(g6)!=6) return false;
   if (explore_game(g7)!=7) return false;
   if (explore_game(g8)!=8) return false;
   if (explore_game(g9)!=2) return false;
   
   return true;
}
Ejemplo n.º 4
0
void
testEllipticalTube::matched_g4_and_dd( void )
{
  double xSemiAxis = 3.0*cm;
  double ySemiAxis = 2.0*cm;
  double zHeight = 5.0*cm;
  std::string name( "fred1" );

  G4EllipticalTube g4( name, xSemiAxis, ySemiAxis, zHeight );
  DDI::EllipticalTube dd(    xSemiAxis, ySemiAxis, zHeight );
  DDEllipticalTube dds = DDSolidFactory::ellipticalTube( name, xSemiAxis, ySemiAxis, zHeight );
  std::cout << std::endl;
  dd.stream( std::cout );
  std::cout << std::endl;

  double g4_volume = g4.GetCubicVolume()/cm3;
  double dd_volume = dd.volume()/cm3;
  double dds_volume = dds.volume()/cm3;
  
  std::cout << "\tg4 volume = " << g4_volume <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd_volume << " cm3" <<  std::endl;
  std::cout << "\tDD Information: " << dds << " vol=" << dds_volume << " cm3" << std::endl;
  
  double tolerance = 0.5;
  
  CPPUNIT_ASSERT( fabs( g4_volume - dd_volume ) < tolerance );
  CPPUNIT_ASSERT( fabs( g4_volume - dds_volume ) < tolerance );
}
Ejemplo n.º 5
0
void Test1()
{
	// 一层
	GeneralList gl("(a,b)");
	gl.Print();

	cout<<"Depth:"<<gl.Depth()<<endl;

	// 两层
	GeneralList g2("(a,b,(c,d))");
	g2.Print();

	cout<<"Depth:"<<g2.Depth()<<endl;

	// 三层 + 有空格的
	GeneralList g3("(a, b,(c,d),(e,(f),h))");
	g3.Print();

	cout<<"Depth:"<<g3.Depth()<<endl;
	cout<<"Size:"<<g3.Size()<<endl;

	// 多层空表嵌套
	GeneralList g4("(((),()))");
	g4.Print();

	cout<<"Depth:"<<g4.Depth()<<endl;

	GeneralList g5(g3);
	g5.Print();

	GeneralList g6 = g5;
	g6.Print();
}
Ejemplo n.º 6
0
void
testParallelepiped::matched_g4_and_dd( void )
{
  double xHalf =  5.*cm;
  double yHalf = 6.*cm;
  double zHalf = 7.*cm;
  double alpha = 15.*deg;
  double theta = 30.*deg;
  double phi = 45.*deg;
  std::string name( "fred1" );

  G4Para g4( name, xHalf, yHalf, zHalf, alpha, theta, phi );
  DDI::Parallelepiped dd(    xHalf, yHalf, zHalf, alpha, theta, phi );
  DDParallelepiped dds = DDSolidFactory::parallelepiped( name, xHalf, yHalf, zHalf, alpha, theta, phi );
  std::cout << std::endl;
  dd.stream( std::cout );
  std::cout << std::endl;

  double g4_volume = g4.GetCubicVolume()/cm3;
  double dd_volume = dd.volume()/cm3;
  double dds_volume = dds.volume()/cm3;
  
  std::cout << "\tg4 volume = " << g4_volume <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd_volume << " cm3" <<  std::endl;
  std::cout << "\tDD Information: " << dds << " vol=" << dds_volume << " cm3" << std::endl;
  
  CPPUNIT_ASSERT( g4_volume == dd_volume );
  CPPUNIT_ASSERT( g4_volume == dds_volume );
}
Ejemplo n.º 7
0
void test() {
    g1(X1());
    g2(X2()); // expected-warning{{C++98 requires an accessible copy constructor for class 'X2' when binding a reference to a temporary; was private}}
    g3(X3()); // expected-warning{{no viable constructor copying parameter of type 'X3'}}
    g4(X4<int>());
    g5(X5());  // Generates a warning in the default argument.
}
Ejemplo n.º 8
0
/*@ assigns \nothing; */
double f4()
{
double tab[2],r;
tab[0]=1.0;
tab[1]=2.0;
r = g4( &tab );
return r;
}
Ejemplo n.º 9
0
/*
   Gauge32( void);
   Gauge32( const unsigned long i);
   Gauge32 ( const Gauge32 &g);
   ~Gauge32();
   SmiUINT32 get_syntax();
   SnmpSyntax *clone() const;
   Gauge32& operator=( const Gauge32 &uli);
   Gauge32& operator=( const unsigned long i);
   operator unsigned long();
   SnmpSyntax& operator=( SnmpSyntax &val);

--  What is a Gauge? According to RFC 1155 section: 3.2.3.4
   This  application-wide type represents a non-negative integer
   which may increase or decrease, but which latches at a maximum
   value of 2^32-1 (4294967295 dec) for gauges.
 */
static void
TestGuage (void)
{
#if !defined (ACE_WIN32)
   long l = LONG_MAX, nl = LONG_MIN;  // limits.h
   unsigned long ul = ULONG_MAX, def = 0;
   int i = INT_MAX, ni = INT_MIN;
   unsigned int ui = UINT_MAX;
   unsigned short us = 10;
   short si = static_cast<short> (65535);

   // constructors
   Gauge32 g1;
   ACE_ASSERT(g1 == def);
   Gauge32 g2(l);
   ACE_ASSERT(g2 == static_cast<unsigned long> (l));
   Gauge32 g3(nl);
   ACE_ASSERT(g3 == static_cast<unsigned long> (nl));
   Gauge32 g4(ul);
   ACE_ASSERT(g4 == ul);
   Gauge32 g5(i);
   ACE_ASSERT(g5 == static_cast<unsigned long> (i));
   Gauge32 g6(ni);
   ACE_ASSERT(g6 == static_cast<unsigned long> (ni));
   Gauge32 g7(ui);
   ACE_ASSERT(g7 == ui);
   Gauge32 *g8 = new Gauge32(g5);
   ACE_ASSERT(g8 != 0);
   delete g8;

  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g1(\"\") [%u]\n",
    (unsigned long)g1));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g2(\"%u\") [%u]\n",
    l, (unsigned long)g2));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g3(\"%u\") [%u]\n",
    nl, (unsigned long)g3));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g4(\"%u\") [%u]\n",
    ul, (unsigned long)g4));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g5(\"%u\") [%u]\n",
    i, (unsigned long)g5));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g6(\"%u\") [%u]\n",
    ni, (unsigned long)g6));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) g7(\"%u\") [%u]\n",
    ui, (unsigned long)g7));

  // assignent
  g1 = g2;  // obj
  ACE_ASSERT(g1 == g2);
  g1 = g1; // self
  ACE_ASSERT(g1 == g1);
  g1 = def; // unsigned long
  ACE_ASSERT(g1 == def);
  g1 = us; // unsigned short
  ACE_ASSERT(g1 == static_cast<unsigned long> (us));
  g1 = si; // unsigned short
  ACE_ASSERT(g1 == static_cast<unsigned long> (si));
#endif /*ACE_WIN32*/
}
Ejemplo n.º 10
0
int main () {
  g1();
  g2();
  g3();
  if (rand) g4();
  g5();
  g6();
  return 0;
}
Ejemplo n.º 11
0
int main( void )
{
    g0();
    g1();
    g2();
    g3();
    g4();
    return 0;
}
Ejemplo n.º 12
0
void f4() {
  void g4(int a, int b = 7);
  {
    void g4(int a, int b = 5);
  }
  void g4(int a = 5, int b);

  // CHECK: call void @_Z2g4ii(i32 5, i32 7)
  g4();
}
Ejemplo n.º 13
0
//
// 9. Torus:
//
// G4Torus(const G4String& pName,
// 	   G4double   pRmin,
// 	   G4double   pRmax,
// 	   G4double   pRtor,
// 	   G4double   pSPhi,
// 	   G4double   pDPhi)
void doTorus(const std::string &name, double rMin, double rMax, double radius, double sPhi, double dPhi) {
  G4Torus g4(name, rMin, rMax, radius, sPhi, dPhi);
  DDI::Torus dd(rMin, rMax, radius, sPhi, dPhi);
  DDTorus dds = DDSolidFactory::torus(name, rMin, rMax, radius, sPhi, dPhi);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 14
0
//
// 1. Box:
//
// G4Box(const G4String& pName,
//       G4double  pX,
//       G4double  pY,
//       G4double  pZ)
void doBox(const std::string &name, double xHalfLength, double yHalfLength, double zHalfLength) {
  G4Box g4(name, xHalfLength, yHalfLength, zHalfLength);
  DDI::Box dd(xHalfLength, yHalfLength, zHalfLength);
  DDBox dds = DDSolidFactory::box(name, xHalfLength, yHalfLength, zHalfLength);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 15
0
//
// 2. Cylindrical Section or Tube:
//
// G4Tubs(const G4String& pName,
//        G4double  pRMin,
//        G4double  pRMax,
//        G4double  pDz,
//        G4double  pSPhi,
//        G4double  pDPhi)
void doTubs(const std::string &name, double rIn, double rOut, double zhalf, double startPhi, double deltaPhi) {
  G4Tubs g4(name, rIn, rOut, zhalf, startPhi, deltaPhi);
  DDI::Tubs dd(zhalf, rIn, rOut, startPhi, deltaPhi);
  DDTubs dds = DDSolidFactory::tubs(name, zhalf, rIn, rOut, startPhi, deltaPhi);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 16
0
int main1(void)
{ 
  int i;
  /* Check vec_extract with a non constant element numbering */
  for(i=0;i<10;i++)
    { 
      if (f(a, i) != (i&0x3))
        abort ();
    }
  
  /* Check vec_extract with a constant element numbering */
  if (f0(a) != 0)
    abort ();
  if (f1(a) != 1)
    abort ();
  if (f2(a) != 2)
    abort ();
  if (f3(a) != 3)
    abort ();
  /* Check that vec_extract works with a constant element higher than
     the number of elements.  */
  if (f4(a) != 0)
    abort ();

  /* Check vec_extract with a non constant element numbering */
  for(i=0;i<10;i++)
    {
      if (g(b, i) != (i&0x7))
        abort ();
    }
  
  /* Check vec_extract with a constant element numbering */
  if (g0(b) != 0)
    abort ();
  if (g1(b) != 1)
    abort ();
  if (g2(b) != 2)
    abort ();
  if (g3(b) != 3)
    abort ();
  if (g4(b) != 4)
    abort ();
  if (g5(b) != 5)
    abort ();
  if (g6(b) != 6)
    abort ();
  if (g7(b) != 7)
    abort ();
  /* Check that vec_extract works with a constant element higher than
     the number of elements.  */
  if (g8(b) != 0)
    abort ();
  
  return 0;
}
Ejemplo n.º 17
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main()
{
    G g1;
    const G g2;

    G g3(g1); //invokes the templated constructor; absence  or presence of of explicit copy-constructor doesn't change this fact

    std::cout << "----" << std::endl;

    G g4(g2); //invokes the copy-constructor; absence or presence of explicit copy-constructor doesn't change this fact
    return 0;
}
Ejemplo n.º 18
0
//
// 4. Parallelepiped:
//
// G4Para(const G4String& pName,                                  
//        G4double   dx,
//        G4double   dy,
//        G4double   dz,
//        G4double   alpha,
//        G4double   theta,
//        G4double   phi)
void
doPara( const std::string& name, double xHalf, double yHalf, 
	double zHalf, double alpha, double theta, double phi )
{
  G4Para g4(name, xHalf, yHalf, zHalf, alpha, theta, phi );
  DDI::Parallelepiped dd( xHalf, yHalf, zHalf, alpha, theta, phi );
  DDParallelepiped dds = DDSolidFactory::parallelepiped( name, xHalf, yHalf, zHalf, alpha, theta, phi );
  dd.stream( std::cout );
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<<  std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 19
0
//
// 7. Sphere or Spherical Shell Section:
//
// G4Sphere(const G4String& pName,                      
// 	    G4double   pRmin,
// 	    G4double   pRmax,
// 	    G4double   pSPhi,
// 	    G4double   pDPhi,
// 	    G4double   pSTheta,
// 	    G4double   pDTheta )
void
doSphere( const std::string& name, double innerRadius, double outerRadius, 
	  double startPhi, double deltaPhi, double startTheta, double deltaTheta )
{  
  G4Sphere g4(name,innerRadius, outerRadius, startPhi, deltaPhi, startTheta, deltaTheta);
  DDI::Sphere dd(innerRadius, outerRadius, startPhi, deltaPhi, startTheta, deltaTheta);
  DDSphere dds = DDSolidFactory::sphere(name, innerRadius, outerRadius, startPhi, deltaPhi, startTheta, deltaTheta);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<<  std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 20
0
//
// 13. General Ellipsoid:
//
// G4Ellipsoid(const G4String& pName,                   
// 	       G4double  pxSemiAxis,
// 	       G4double  pySemiAxis,
// 	       G4double  pzSemiAxis,
// 	       G4double  pzBottomCut=0,
// 	       G4double  pzTopCut=0)
void
doEllipsoid( const std::string& name, double xSemiAxis, double ySemiAxis, 
	     double zSemiAxis, double zBottomCut, double zTopCut )
{  
  G4Ellipsoid g4(name,xSemiAxis,ySemiAxis,zSemiAxis,zBottomCut, zTopCut);
  DDI::Ellipsoid dd(xSemiAxis,ySemiAxis,zSemiAxis,zBottomCut, zTopCut);
  DDEllipsoid dde = DDSolidFactory::ellipsoid(name, xSemiAxis, ySemiAxis, zSemiAxis, zBottomCut, zTopCut);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<<  std::endl;
  std::cout << "\tDD Information: " << dde << " vol= " << dde.volume() << std::endl;
}
Ejemplo n.º 21
0
//
// 5. Trapezoid:
//
// G4Trd(const G4String& pName,
//       G4double  dx1,
//       G4double  dx2,
//       G4double  dy1,
//       G4double  dy2,
//       G4double  dz)
void doTrd(const std::string &name, double dx1, double dx2, double dy1, double dy2, double dz) {
  G4Trd g4(name, dx1, dx2, dy1, dy2, dz);
  /////////////////////////////////////////
  // DDD does not have direct implementation of Trd.
  // Use generic trapezoid instead.
  DDI::Trap dd(dz, 0.0 /* pTheta */, 0.0 /* pPhi */, dy1, dx1, dx1, 0.0 /* pAlp1 */, dy2, dx2, dx2, 0.0 /* pAlp2 */);
  DDTrap dds = DDSolidFactory::trap(
      name, dz, 0.0 /* pTheta */, 0.0 /* pPhi */, dy1, dx1, dx1, 0.0 /* pAlp1 */, dy2, dx2, dx2, 0.0 /* pAlp2 */);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 22
0
void
doPolyhedra2( const std::string& name, int sides, double phiStart, double phiTotal,
	      const std::vector<double> & z,
	      const std::vector<double> & r )
{  
  G4Polyhedra g4( name, phiStart, phiTotal, sides, z.size(), &r[0], &z[0] );
  DDI::Polyhedra dd( sides, phiStart, phiTotal, z, r );
  DDPolyhedra dds = DDSolidFactory::polyhedra( name, sides, phiStart, phiTotal, z, r );
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<<  std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 23
0
//
// 10. Polycons:
//
// G4Polycone(const G4String& pName,
// 	   G4double   phiStart,
// 	   G4double   phiTotal,
// 	   G4int      numZPlanes,
// 	   const G4double   zPlane[],
// 	   const G4double   rInner[],
// 	   const G4double   rOuter[])
//
// G4Polycone(const G4String& pName,
// 	   G4double   phiStart,
// 	   G4double   phiTotal,
// 	   G4int      numRZ,
// 	   const G4double  r[],
// 	   const G4double  z[])
void doPolycone1(const std::string &name,
                 double phiStart,
                 double phiTotal,
                 const std::vector<double> &z,
                 const std::vector<double> &rInner,
                 const std::vector<double> &rOuter) {
  G4Polycone g4(name, phiStart, phiTotal, z.size(), &z[0], &rInner[0], &rOuter[0]);
  DDI::Polycone dd(phiStart, phiTotal, z, rInner, rOuter);
  DDPolycone dds = DDSolidFactory::polycone(name, phiStart, phiTotal, z, rInner, rOuter);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 24
0
//
// 6. Generic Trapezoid:
//
// G4Trap(const G4String& pName,                        
//        G4double   pZ,
//        G4double   pY,
//        G4double   pX,
//        G4double   pLTX)
//
// G4Trap(const G4String& pName,                         
//        G4double   pDz,   G4double   pTheta,
//        G4double   pPhi,  G4double   pDy1,
//        G4double   pDx1,  G4double   pDx2,
//        G4double   pAlp1, G4double   pDy2,
//        G4double   pDx3,  G4double   pDx4,
//        G4double   pAlp2)
void
doTrap( const std::string& name, double dz, double pTheta, double pPhi,
	double pDy1, double pDx1, double pDx2, double pAlp1,
	double pDy2, double pDx3, double pDx4, double pAlp2 )
{
  G4Trap g4( name, dz, pTheta, pPhi, pDy1, pDx1, pDx2, pAlp1, pDy2, pDx3, pDx4, pAlp2 );
  
  // Note, the order of parameters is different:
  DDI::Trap dd( dz, pTheta, pPhi, pDy2, pDx3, pDx4, pAlp1, pDy1, pDx1, pDx2, pAlp2 );
  DDTrap dds = DDSolidFactory::trap( name, dz, pTheta, pPhi, pDy2, pDx3, pDx4, pAlp1, pDy1, pDx1, pDx2, pAlp2 );
  dd.stream( std::cout );
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<<  std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 25
0
/**
 * Encrypt a single block of data.
 */
void skipjack_encrypt(byte tab[10][256], byte in[8], byte out[8]) {
	word32 w1, w2, w3, w4;

	w1 = (in[0] << 8) + in[1];
	w2 = (in[2] << 8) + in[3];
	w3 = (in[4] << 8) + in[5];
	w4 = (in[6] << 8) + in[7];

	/* stepping rule A: */
	g0(tab, w1); w4 ^= w1 ^ 1;
	g1(tab, w4); w3 ^= w4 ^ 2;
	g2(tab, w3); w2 ^= w3 ^ 3;
	g3(tab, w2); w1 ^= w2 ^ 4;
	g4(tab, w1); w4 ^= w1 ^ 5;
	g0(tab, w4); w3 ^= w4 ^ 6;
	g1(tab, w3); w2 ^= w3 ^ 7;
	g2(tab, w2); w1 ^= w2 ^ 8;

	/* stepping rule B: */
	w2 ^= w1 ^  9; g3(tab, w1);
	w1 ^= w4 ^ 10; g4(tab, w4);
	w4 ^= w3 ^ 11; g0(tab, w3);
	w3 ^= w2 ^ 12; g1(tab, w2);
	w2 ^= w1 ^ 13; g2(tab, w1);
	w1 ^= w4 ^ 14; g3(tab, w4);
	w4 ^= w3 ^ 15; g4(tab, w3);
	w3 ^= w2 ^ 16; g0(tab, w2);

	/* stepping rule A: */
	g1(tab, w1); w4 ^= w1 ^ 17;
	g2(tab, w4); w3 ^= w4 ^ 18;
	g3(tab, w3); w2 ^= w3 ^ 19;
	g4(tab, w2); w1 ^= w2 ^ 20;
	g0(tab, w1); w4 ^= w1 ^ 21;
	g1(tab, w4); w3 ^= w4 ^ 22;
	g2(tab, w3); w2 ^= w3 ^ 23;
	g3(tab, w2); w1 ^= w2 ^ 24;

	/* stepping rule B: */
	w2 ^= w1 ^ 25; g4(tab, w1);
	w1 ^= w4 ^ 26; g0(tab, w4);
	w4 ^= w3 ^ 27; g1(tab, w3);
	w3 ^= w2 ^ 28; g2(tab, w2);
	w2 ^= w1 ^ 29; g3(tab, w1);
	w1 ^= w4 ^ 30; g4(tab, w4);
	w4 ^= w3 ^ 31; g0(tab, w3);
	w3 ^= w2 ^ 32; g1(tab, w2);

	out[0] = (byte)(w1 >> 8); out[1] = (byte)w1;
	out[2] = (byte)(w2 >> 8); out[3] = (byte)w2;
	out[4] = (byte)(w3 >> 8); out[5] = (byte)w3;
	out[6] = (byte)(w4 >> 8); out[7] = (byte)w4;

}
Ejemplo n.º 26
0
//
// 8. Full Solid Sphere:
//
// G4Orb(const G4String& pName,                                   
//       G4double  pRmax)
void
doOrb( const std::string& name, double radius )
{  
  G4Orb g4(name,radius);
  DDI::Orb dd(radius);
  DDI::Sphere dds(0.*deg, radius, 0.*deg, 360.*deg, 0., 180.*deg);
  DDOrb ddo = DDSolidFactory::orb(name, radius);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume()/cm3 <<" cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume()/cm3 << " cm3"<<  std::endl;
  std::cout << "\tDD Information: " << ddo << " vol= " << ddo.volume() << std::endl;
  std::cout << "\tcross check sphere " << std::endl;
  dds.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tsphere volume = " << dds.volume()/cm3 << " cm3" << std::endl;
}
Ejemplo n.º 27
0
Archivo: main.cpp Proyecto: CCJY/coliru
int main()
{
   A a;
   B b;
   C c;

   Gadget g1( a, b, c );
   Gadget g2( b, c, a );
   Gadget g3( a, b ); // uses a default-constructed C
   Gadget g4( a, c ); // uses a default-constructed B
   Gadget g5( c ); // uses a default-constructed A and B
   Gadget g6; // uses a default-constructed A, B and C

   // fails to compile:
   // Gadget gf1( a, a ); // duplicate type
   // Gadget gf2( a, b, 42 ); // invalid type
}
Ejemplo n.º 28
0
void doPolycone2(const std::string &name,
                 double phiStart,
                 double phiTotal,
                 const std::vector<double> &z,
                 const std::vector<double> &r) {
  std::cout << "### doPolycone_RZ: "
            << "phi1=" << phiStart / deg << " phi2=" << phiTotal / deg << " N= " << z.size() << std::endl;
  for (size_t i = 0; i < z.size(); ++i) {
    std::cout << " R= " << r[i] << " Z= " << z[i] << std::endl;
  }
  G4Polycone g4(name, phiStart, phiTotal, z.size(), &r[0], &z[0]);
  DDI::Polycone dd(phiStart, phiTotal, z, r);
  DDPolycone dds = DDSolidFactory::polycone(name, phiStart, phiTotal, z, r);
  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}
Ejemplo n.º 29
0
/**
 * Encrypt a single block of data.
 */
void SKIPJACK::Enc::ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const
{
	word w1, w2, w3, w4;
	Block::Get(inBlock)(w4)(w3)(w2)(w1);

	/* stepping rule A: */
	g0(tab, w1); w4 ^= w1 ^ 1;
	g1(tab, w4); w3 ^= w4 ^ 2;
	g2(tab, w3); w2 ^= w3 ^ 3;
	g3(tab, w2); w1 ^= w2 ^ 4;
	g4(tab, w1); w4 ^= w1 ^ 5;
	g0(tab, w4); w3 ^= w4 ^ 6;
	g1(tab, w3); w2 ^= w3 ^ 7;
	g2(tab, w2); w1 ^= w2 ^ 8;

	/* stepping rule B: */
	w2 ^= w1 ^  9; g3(tab, w1);
	w1 ^= w4 ^ 10; g4(tab, w4);
	w4 ^= w3 ^ 11; g0(tab, w3);
	w3 ^= w2 ^ 12; g1(tab, w2);
	w2 ^= w1 ^ 13; g2(tab, w1);
	w1 ^= w4 ^ 14; g3(tab, w4);
	w4 ^= w3 ^ 15; g4(tab, w3);
	w3 ^= w2 ^ 16; g0(tab, w2);

	/* stepping rule A: */
	g1(tab, w1); w4 ^= w1 ^ 17;
	g2(tab, w4); w3 ^= w4 ^ 18;
	g3(tab, w3); w2 ^= w3 ^ 19;
	g4(tab, w2); w1 ^= w2 ^ 20;
	g0(tab, w1); w4 ^= w1 ^ 21;
	g1(tab, w4); w3 ^= w4 ^ 22;
	g2(tab, w3); w2 ^= w3 ^ 23;
	g3(tab, w2); w1 ^= w2 ^ 24;

	/* stepping rule B: */
	w2 ^= w1 ^ 25; g4(tab, w1);
	w1 ^= w4 ^ 26; g0(tab, w4);
	w4 ^= w3 ^ 27; g1(tab, w3);
	w3 ^= w2 ^ 28; g2(tab, w2);
	w2 ^= w1 ^ 29; g3(tab, w1);
	w1 ^= w4 ^ 30; g4(tab, w4);
	w4 ^= w3 ^ 31; g0(tab, w3);
	w3 ^= w2 ^ 32; g1(tab, w2);

	Block::Put(xorBlock, outBlock)(w4)(w3)(w2)(w1);
}
Ejemplo n.º 30
0
//
// 25. Extruded Polygon:
//
// The extrusion of an arbitrary polygon (extruded solid)
// with fixed outline in the defined Z sections can be defined as follows
// (in a general way, or as special construct with two Z sections):
//
//    G4ExtrudedSolid(const G4String& pName,
//                    std::vector<G4TwoVector> polygon,
//                    std::vector<ZSection> zsections)
//
void doExtrudedPgon(const std::string &name,
                    const std::vector<double> x,
                    const std::vector<double> y,
                    const std::vector<double> z,
                    const std::vector<double> zx,
                    const std::vector<double> zy,
                    const std::vector<double> zscale) {
  std::vector<G4TwoVector> polygon;
  std::vector<G4ExtrudedSolid::ZSection> zsections;
  for (unsigned int it = 0; it < x.size(); ++it)
    polygon.emplace_back(x[it], y[it]);
  for (unsigned int it = 0; it < z.size(); ++it)
    zsections.emplace_back(z[it], G4TwoVector(zx[it], zy[it]), zscale[it]);
  G4ExtrudedSolid g4(name, polygon, zsections);
  DDI::ExtrudedPolygon dd(x, y, z, zx, zy, zscale);
  DDExtrudedPolygon dds = DDSolidFactory::extrudedpolygon(name, x, y, z, zx, zy, zscale);

  dd.stream(std::cout);
  std::cout << std::endl;
  std::cout << "\tg4 volume = " << g4.GetCubicVolume() / cm3 << " cm3" << std::endl;
  std::cout << "\tdd volume = " << dd.volume() / cm3 << " cm3" << std::endl;
  std::cout << "\tDD Information: " << dds << " vol= " << dds.volume() << std::endl;
}