Ejemplo n.º 1
0
void testRect()
{
	AArrayCanvas<u4> canvas(10,10,' ');
	canvas.drawRect(0,0,2,2,u4('A'));
	canvas.drawRect(9,9,5,6,u4('A'));

	for (u2 y=0;	y<canvas.getSizeY(); ++y) {
		for (u2 x=0; x<canvas.getSizeX(); ++x) {
			std::cout << (char)canvas.at(x,y);
		}
		std::cout << std::endl;
	}
}
Ejemplo n.º 2
0
// Write the compact table's buckets
void CompactHashtableWriter::dump_table(NumberSeq* summary) {
  u4 offset = 0;
  for (int index = 0; index < _num_buckets; index++) {
    GrowableArray<Entry>* bucket = _buckets[index];
    int bucket_size = bucket->length();
    if (bucket_size == 1) {
      // bucket with one entry is compacted and only has the symbol offset
      _compact_buckets->at_put(index, BUCKET_INFO(offset, VALUE_ONLY_BUCKET_TYPE));

      Entry ent = bucket->at(0);
      _compact_entries->at_put(offset++, ent.value());
      _num_value_only_buckets++;
    } else {
      // regular bucket, each entry is a symbol (hash, offset) pair
      _compact_buckets->at_put(index, BUCKET_INFO(offset, REGULAR_BUCKET_TYPE));

      for (int i=0; i<bucket_size; i++) {
        Entry ent = bucket->at(i);
        _compact_entries->at_put(offset++, u4(ent.hash())); // write entry hash
        _compact_entries->at_put(offset++, ent.value());
      }
      if (bucket_size == 0) {
        _num_empty_buckets++;
      } else {
        _num_other_buckets++;
      }
    }
    summary->add(bucket_size);
  }

  // Mark the end of the buckets
  _compact_buckets->at_put(_num_buckets, BUCKET_INFO(offset, TABLEEND_BUCKET_TYPE));
  assert(offset == (u4)_compact_entries->length(), "sanity");
}
Ejemplo n.º 3
0
	void testParse4() {

		// Test parameters
		vmime::utility::url u1("", "");

		VASSERT_EQ("1.1", true, parseHelper(u1, "proto://host/path?p1=v1&p2=v2"));
		VASSERT_EQ("1.2", "v1", u1.getParams()["p1"]);
		VASSERT_EQ("1.3", "v2", u1.getParams()["p2"]);
		VASSERT_EQ("1.4", "/path", u1.getPath());

		vmime::utility::url u2("", "");

		VASSERT_EQ("2.1", true, parseHelper(u2, "proto://host/path?p1=v1&p2"));
		VASSERT_EQ("2.2", "v1", u2.getParams()["p1"]);
		VASSERT_EQ("2.3", "p2", u2.getParams()["p2"]);
		VASSERT_EQ("2.4", "/path", u2.getPath());

		vmime::utility::url u3("", "");

		VASSERT_EQ("3.1", true, parseHelper(u3, "proto://host/?p1=v1&p2=v2"));
		VASSERT_EQ("3.2", "v1", u3.getParams()["p1"]);
		VASSERT_EQ("3.3", "v2", u3.getParams()["p2"]);
		VASSERT_EQ("3.4", "", u3.getPath());

		vmime::utility::url u4("", "");

		VASSERT_EQ("4.1", true, parseHelper(u4, "proto://host/path?p1=%3D&%3D=v2"));
		VASSERT_EQ("4.2", "=", u4.getParams()["p1"]);
		VASSERT_EQ("4.3", "v2", u4.getParams()["="]);
		VASSERT_EQ("4.4", "/path", u4.getPath());
	}
Ejemplo n.º 4
0
int main()
{
  const unit<1,0> u1;
  const unit<2,0> u2;
 
  unit<-1,0> u3( u1 / u2 );
  unit< 3,0> u4( u1 * u2 );
}
Ejemplo n.º 5
0
void CompactSymbolTableWriter::add(unsigned int hash, Symbol *symbol) {
  address base_address = address(MetaspaceShared::shared_rs()->base());

  uintx deltax = address(symbol) - base_address;
  // The symbols are in RO space, which is smaler than MAX_SHARED_DELTA.
  // The assert below is just to be extra cautious.
  assert(deltax <= MAX_SHARED_DELTA, "the delta is too large to encode");
  u4 delta = u4(deltax);

  CompactHashtableWriter::add(hash, delta);
}
Ejemplo n.º 6
0
/*
 * Creates a new tile with a random x/y position, width, height, and color,
 * and adds it to the given tile list.
 */
void MainWindow::addRandomTile(TileList &tlist)
{
    Tile tile;
    std::random_device rd;

    // possibly use the same random numbers every time for testing
    static std::default_random_engine e(RANDOM ? rd() : 42);

    std::uniform_int_distribution<unsigned> u1(MIN_COLOR, MAX_COLOR);
    std::uniform_int_distribution<unsigned> u2(MIN_SIZE, MAX_SIZE);
    tile.width = u2(e);
    tile.height = u2(e);
    std::uniform_int_distribution<unsigned> u3(0, SCENE_WIDTH - tile.width - 1);
    std::uniform_int_distribution<unsigned> u4(0, SCENE_HEIGHT - tile.height - 1);
    tile.x = u3(e);
    tile.y = u4(e);
    tile.r = u1(e);
    tile.g = u1(e);
    tile.b = u1(e);
    tlist.addTile(tile);
}
Ejemplo n.º 7
0
void OmniRobot::init()
{
    period = 200;
    xw = 75.0; //mm
    yw = 75.0; //mm
    Dw = 50.0; //mm

    vector<float> u1 (2); u1(0) =  c1; u1(1) =  c1;
    vector<float> u2 (2); u2(0) =  c1; u2(1) = -c1;
    vector<float> u3 (2); u3(0) =  c1; u3(1) =  c1;
    vector<float> u4 (2); u4(0) =  c1; u4(1) = -c1;

    vector<float> n1 (2); n1(0) =  c1; n1(1) = -c1;
    vector<float> n2 (2); n2(0) = -c1; n2(1) = -c1;
    vector<float> n3 (2); n3(0) =  c1; n3(1) = -c1;
    vector<float> n4 (2); n4(0) = -c1; n4(1) = -c1;

    vector<float> b1 (2); b1(0) =  xw; b1(1) =  yw;
    vector<float> b2 (2); b2(0) =  xw; b2(1) = -yw;
    vector<float> b3 (2); b3(0) = -xw; b3(1) = -yw;
    vector<float> b4 (2); b4(0) = -xw; b4(1) =  yw;

    Mt(0,0) = n1(0); Mt(0,1) = n1(1); Mt(0,2) = b1(0)*u1(0) + b1(1)*u1(1);
    Mt(1,0) = n2(0); Mt(1,1) = n2(1); Mt(1,2) = b2(0)*u2(0) + b2(1)*u2(1);
    Mt(2,0) = n3(0); Mt(2,1) = n3(1); Mt(2,2) = b3(0)*u3(0) + b3(1)*u3(1);
    Mt(3,0) = n4(0); Mt(3,1) = n3(1); Mt(3,2) = b4(0)*u4(0) + b4(1)*u4(1);

    Mt = -1 * Mt;

    cmd(0) = 0.0; cmd(1) = 0.0; cmd(2) = 0.0;
    pwm(0) = 0.0; pwm(1) = 0.0; pwm(2) = 0.0; pwm(3) = 0.0;

    omniState = INIT_MODE;
    movementMode = ROTATE_MODE;
    power = 20;
    pplus = 1;
}
Ejemplo n.º 8
0
/*
     SnmpUInt32( void);
     SnmpUInt32 (const unsigned long i);
     SnmpUInt32( const SnmpUInt32 &c);
     virtual ~SnmpUInt32();
     virtual SmiUINT32 get_syntax();
     SnmpUInt32& operator=( const unsigned long i);
     SnmpUInt32& operator=( const SnmpUInt32 &uli);
     operator unsigned long();
     virtual char *to_string();
     virtual SnmpSyntax *clone() const;
     SnmpSyntax& operator=( SnmpSyntax &val);
     int valid() const;
 */
static void TestUnsignedInteger32()
{
  // constructors
   SnmpUInt32 u1;
   ACE_ASSERT(u1 == def);
   SnmpUInt32 u2(l);
   ACE_ASSERT(u2 == l);
   SnmpUInt32 u3(nl);
   ACE_ASSERT(u3 == nl);
   SnmpUInt32 u4(ul);
   ACE_ASSERT(u4 == ul);
   SnmpUInt32 u5(i);
   ACE_ASSERT(u5 == i);
   SnmpUInt32 u6(ni);
   ACE_ASSERT(u6 == ni);
   SnmpUInt32 u7(ui);
   ACE_ASSERT(u7 == ui);
   SnmpUInt32 *u8 = new SnmpUInt32(u5);
   ACE_ASSERT(u8 != 0);
   delete u8;

  ACE_DEBUG ((LM_DEBUG, "(%P|%t) u1(\"\") [%u]\n",
    (unsigned long)u1));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) u2(\"%u\") [%u]\n",
    l, (unsigned long)u2));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) u3(\"%u\") [%u]\n",
    nl, (unsigned long)u3));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) u4(\"%u\") [%u]\n",
    ul, (unsigned long)u4));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) u5(\"%u\") [%u]\n",
    i, (unsigned long)u5));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) u6(\"%u\") [%u]\n",
    ni, (unsigned long)u6));
  ACE_DEBUG ((LM_DEBUG, "(%P|%t) u7(\"%u\") [%u]\n",
    ui, (unsigned long)u7));

 // assignent
  u1 = u2;  // obj
  ACE_ASSERT(u1 == u2);
  u1 = u1; // self
  ACE_ASSERT(u1 == u1);
  u1 = def; // unsigned long
  ACE_ASSERT(u1 == def);
  u1 = us; // unsigned short
  ACE_ASSERT(u1 == us);
  u1 = si; // unsigned short
  ACE_ASSERT(u1 == si);
}
Ejemplo n.º 9
0
  static inline u4   get_native_u4(address p) {
    switch (intptr_t(p) & 3) {
     case 0:  return *(u4*)p;

     case 2:  return (  u4( ((u2*)p)[0] ) << 16  ) 
                   | (  u4( ((u2*)p)[1] )                  );

    default:  return ( u4(p[0]) << 24 )
                   | ( u4(p[1]) << 16 ) 
                   | ( u4(p[2]) <<  8 )
                   |   u4(p[3]);
    }
  }
Ejemplo n.º 10
0
	void testParse2() {

		// Now, test some ill-formed URLs

		// -- missing protocol
		vmime::utility::url u1("", "");
		VASSERT_EQ("1", false, parseHelper(u1, "://host"));

		// -- port can contain only digits
		vmime::utility::url u2("", "");
		VASSERT_EQ("2", false, parseHelper(u2, "proto://host:abc123"));

		// -- no host specified
		vmime::utility::url u3("", "");
		VASSERT_EQ("3", false, parseHelper(u3, "proto:///path"));

		// -- no protocol separator (://)
		vmime::utility::url u4("", "");
		VASSERT_EQ("4", false, parseHelper(u4, "protohost/path"));
	}
Ejemplo n.º 11
0
 static inline u4   swap_u4(u4 x)  {
   address p = (address) &x;
   return ( (u4(p[0]) << 24) | (u4(p[1]) << 16) | (u4(p[2]) << 8) | u4(p[3])) ;
 }
TEST(sql_Book_on_shelf, all_base_operations) {
    soci::session sql(dal::soci_session_factory(), true);
    sql.begin();
    dal::BookOnShelf r(sql);
    
    boost::uuids::random_generator gen;
    bl::db_id b1( gen());
    bl::db_id b2( gen());
    bl::db_id b3( gen());
    bl::db_id s1( gen());
    bl::db_id s2( gen());
    bl::db_id s3( gen());

    std::pair<bl::db_id, bl::db_id> u1(b1,s1);
    std::pair<bl::db_id, bl::db_id> u2(b2,s2);
    std::pair<bl::db_id, bl::db_id> u3(b2,s3);
    std::pair<bl::db_id, bl::db_id> u4(b3,s2);
    
    EXPECT_EQ(0,r.count());
    r.insert(u1);
    r.insert(u2);
    r.insert(u3);
    r.insert(u4);
    EXPECT_EQ(4,r.count());
    
    std::list<std::pair<bl::db_id, bl::db_id> > result;
    result = r.rows_shelfs_for_book(b1.id());
    EXPECT_EQ(1,result.size());
    std::pair<bl::db_id, bl::db_id>
    from_data_base(result.front());
    EXPECT_TRUE( u1 == from_data_base);
    result = r.rows_book_on_shelf( s1.id());
    EXPECT_EQ(1,result.size());
    from_data_base = result.front();
    EXPECT_TRUE( u1 == from_data_base);
    
    EXPECT_EQ(1,r.count_shelf(s1.id()));
    EXPECT_EQ(1,r.count_books(b1.id()));
    EXPECT_EQ(1,r.count_books(b3.id()));
    EXPECT_EQ(2,r.count_shelf(s2.id()));
    EXPECT_EQ(2,r.count_books(b2.id()));
    r.del_book_records(b2.id());
    EXPECT_EQ(0,r.count_books(b2.id()));
    EXPECT_EQ(1,r.count_shelf(s2.id()));
    r.del_shelf_records(s2.id());
    EXPECT_EQ(0,r.count_shelf(s2.id()));

    EXPECT_EQ(1,r.count());
    r.delete_all_rows();
    EXPECT_EQ(0,r.count());
    
    
    
    try
    {
        r.insert(u1);
        r.insert(u1);//must throw
        EXPECT_TRUE(false);
    }
    catch (...)
    {
    }
    

    
    sql.rollback();
}
Ejemplo n.º 13
0
size_t AFragmentString::parse(const AString& str)
{
  size_t iRet = AConstant::npos;
  size_t iX = 0;
  AString strHold;
  while(iX < str.getSize())
  {
    switch(str[iX])
    {
      case '\\' :
      { 
        ++iX;
        if (str.getSize() > iX)
        {
          strHold += str[iX];
          iRet = iX;
        }
        else
        {
          //a_String truncated
          iRet = iX - 1;
          return iRet;
        }
      }
      break;

      case '(' :
      {
        iX++;
        if (str.getSize() > iX)
        {
          size_t iF = str.find(')', iX+1);
          if (iF != AConstant::npos)
          {
            AASSERT(this, iF >= iX);
            if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); iRet = iX-1; }
            AString strT;
            str.peek(strT, iX, iF-iX);
            iX = iF;  // advance offset after extraction

            u1 b;
            u4 n[2];
            
            b = (u1)strT.toInt();
            if (b > 9)
              b = 9;
            if ((iF = strT.find(',')) == AConstant::npos)
            {
              // Only 1 number, the digit value
              long stop = 10;
              for (int i=1; i<b; ++i)
                stop *= 10;
              m_Container.push_back(new AFragmentCounter(b, u4(stop-1)));
            }
            else
            {
              AString str1;
              strT.peek(str1, iF + 1);
              if ((iF = str1.find(',')) == AConstant::npos)
              {                             
                n[0] = str1.toU4();
                m_Container.push_back(new AFragmentCounter(b, n[0]));
              }
              else
              {
                AString strQ;
                str1.peek(strQ, 0, iF);
                n[0] = strQ.toU4();
                strQ.clear();
                str1.peek(strQ, iF+1);
                n[1] = strQ.toU4();
                if ((iF = str1.find(',', iF+1)) == AConstant::npos)
                  m_Container.push_back(new AFragmentCounter(b, n[0], n[1]));
                else {
                  strQ.clear();
                  str1.peek(strQ, iF+1);
                  m_Container.push_back(new AFragmentCounter(b, n[0], n[1], strQ.toInt()));
                }
              }
            }
            iRet = iX;
          }
          else 
          {
            //a_Closing tag not found
            iRet = iX-1;
            return iRet;
          }
        }
        else
        {
          //a_String is truncated
          iRet = iX-1;
          return iRet;
        }
      }
      break;

      case '{' :
      {
        ++iX;
        if (str.getSize() > iX)
        {
          size_t iF = str.find('}', iX+1);
          if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); iRet = iX-1;}
          if (iF != AConstant::npos)
          {
            AASSERT(this, iF >= iX);
            AString strT;
            str.peek(strT, iX, iF-iX);
            char cX;
            while (!strT.isEmpty())
            {
              cX = strT.get();
              switch (cX)
              {
                case '#': m_Container.push_back(new AFragmentSet(AFragmentSet::Numeric)); break;
                case '&': m_Container.push_back(new AFragmentSet(AFragmentSet::LowercaseAlpha)); break;
                case '@': m_Container.push_back(new AFragmentSet(AFragmentSet::UppercaseAlpha)); break;
                case '%': m_Container.push_back(new AFragmentSet(AFragmentSet::LowercaseAlphaNumeric)); break;
                case '^': m_Container.push_back(new AFragmentSet(AFragmentSet::UppercaseAlphaNumeric)); break;
                case '?': m_Container.push_back(new AFragmentSet(AFragmentSet::AlphaNumeric)); break;
                default : strHold += cX;
              }
            }
            iX = iF;
            iRet = iX;
          }
          else
          {
            //a_Closing tag not found
            iRet = iX-1;
            return iRet;
          }
        }
        else
        {
          //a_String is truncated
          iRet = iX-1;
          return iRet;
        }
      }
      break;

      case '[' :
      {
        size_t iF = str.find(']', iX+1);
        if (iF != AConstant::npos)
        {
          AASSERT(this, iF >= iX);
          if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); }
          AString strT;
          str.peek(strT, iX + 1, iF - iX - 1);
          m_Container.push_back(new AFragmentSet(strT));
          iX = iF;
          iRet = iX;
        }
        else
        {
          //a_Closing tag not found, return iRet at point of error
          iRet = iX;
          return iRet;
        }
      }
      break;

      case '<' :
      {
        size_t iF = str.find('>', iX+1);
        if (iF != AConstant::npos)
        {
          AASSERT(this, iF >= iX);
          if (!strHold.isEmpty()) { m_Container.push_back(new AFragmentConstant(strHold)); strHold.clear(); }
          AString strT;
          str.peek(strT, iX + 1, iF - iX - 1);
          m_Container.push_back(new AFragmentOdometer(strT.toSize_t()));
          iX = iF;
          iRet = iX;
        }
        else
        {
          //a_Closing tag not found, return iRet at point of error
          iRet = iX;
          return iRet;
        }
      }
      break;

      default  : 
        strHold += str[iX];
        iRet = iX;
    }
    iX++;
  }

  if (!strHold.isEmpty()) {
    m_Container.push_back(new AFragmentConstant(strHold));
  }

  //a_If we got here we have succeeded
  iRet = iX;
  m_Finished = false;

  return iRet;
}
Ejemplo n.º 14
0
int cpp_main(int, char * [])
{
  be::endian_log = false;

  //  make sure some simple things work

  be::big_int32_t o1(1);
  be::big_int32_t o2(2L);
  be::big_int32_t o3(3LL);
  be::big_int64_t o4(1);

  //  use cases; if BOOST_ENDIAN_LOG is defined, will output to clog info on
  //  what overloads and conversions are actually being performed.

  be::endian_log = true;

  std::clog << "set up test values\n";
  be::big_int32_t      big(12345);
  be::little_uint16_t  little_u(10);
  be::big_int64_t      result;

  // this is the use case that is so irritating that it caused the endian
  // constructors to be made non-explicit
  std::clog << "\nf(1234) where f(big_int32_t)\n";
  f_big_int32_ut(1234);

  std::clog << "\nresult = big\n";
  result = big;

  std::clog << "\nresult = +big\n";
  result = +big;

  std::clog << "\nresult = -big\n";
  result = -big;

  std::clog << "\n++big\n";
  ++big;

  std::clog << "\nresult = big++\n";
  result = big++;

  std::clog << "\n--big\n";
  --big;

  std::clog << "\nbig--\n";
  big--;

  std::clog << "\nresult = big * big\n";
  result = big * big;

  std::clog << "\nresult = big * big\n";
  result = big * big;

  std::clog << "\nresult = big * little_u\n";
  result = big * little_u;

  std::clog << "\nbig *= little_u\n";
  big *= little_u;

  std::clog << "\nresult = little_u * big\n";
  result = little_u * big;

  std::clog << "\nresult = big * 5\n";
  result = big * 5;

  std::clog << "\nbig *= 5\n";
  big *= 5;

  std::clog << "\nresult = 5 * big\n";
  result = 5 * big;

  std::clog << "\nresult = little_u * 5\n";
  result = little_u * 5;

  std::clog << "\nresult = 5 * little_u\n";
  result = 5 * little_u;

  std::clog << "\nresult = 5 * 10\n";
  result = 5 * 10;
  std::clog << "\n";

  //  test from Roland Schwarz that detected ambiguities; these ambiguities
  //  were eliminated by BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
  unsigned u;
  be::little_uint32_t u1;
  be::little_uint32_t u2;

  u = 9;
  u1 = 1;
  std::clog << "\nu2 = u1 + u\n";
  u2 = u1 + u;
  std::clog << "\n";

  // variations to detect ambiguities

  be::little_uint32_t u3 = u1 + 5;
  u3 = u1 + 5u;

  if (u1 == 5)
    {}
  if (u1 == 5u)
    {}

  u1 += 5;
  u1 += 5u;

  u2 = u1 + 5;
  u2 = u1 + 5u;

  //  one more wrinkle
  be::little_uint16_t u4(3);
  u4 = 3;
  std::clog << "\nu2 = u1 + u4\n";
  u2 = u1 + u4;
  std::clog << "\n";

  be::endian_log = false;

  test_inserter_and_extractor();
    
  //  perform the indicated test on ~60*60 operand types

  op_test<default_construct>();
  op_test<construct>();  // includes copy construction
  op_test<initialize>();
  op_test<assign>();
  op_test<relational>();
  op_test<op_plus>();
  op_test<op_star>();

  return boost::report_errors();
}
Ejemplo n.º 15
0
void TestBandMatrixArith_D1()
{
    std::vector<tmv::BandMatrixView<T> > b;
    std::vector<tmv::BandMatrixView<std::complex<T> > > cb;
    MakeBandList(b,cb);

    const int N = b[0].rowsize();

    tmv::Matrix<T> a1(N,N);
    for (int i=0; i<N; ++i) for (int j=0; j<N; ++j) a1(i,j) = T(3+i-5*j);
    tmv::Matrix<std::complex<T> > ca1(N,N);
    for (int i=0; i<N; ++i) for (int j=0; j<N; ++j)
        ca1(i,j) = std::complex<T>(3+i-5*j,4-8*i-j);

    tmv::UpperTriMatrix<T,tmv::NonUnitDiag|tmv::RowMajor> u1(a1);
    tmv::UpperTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::RowMajor> cu1(ca1);
    tmv::UpperTriMatrixView<T> u1v = u1.view();
    tmv::UpperTriMatrixView<std::complex<T> > cu1v = cu1.view();
    tmv::UpperTriMatrix<T,tmv::NonUnitDiag> u1x = u1v;
    tmv::UpperTriMatrix<std::complex<T>,tmv::NonUnitDiag> cu1x = cu1v;

#if (XTEST & 2)
    tmv::UpperTriMatrix<T,tmv::UnitDiag|tmv::RowMajor> u2(a1);
    tmv::UpperTriMatrix<T,tmv::NonUnitDiag|tmv::ColMajor> u3(a1);
    tmv::UpperTriMatrix<T,tmv::UnitDiag|tmv::ColMajor> u4(a1);
    tmv::LowerTriMatrix<T,tmv::NonUnitDiag|tmv::RowMajor> l1(a1);
    tmv::LowerTriMatrix<T,tmv::UnitDiag|tmv::RowMajor> l2(a1);
    tmv::LowerTriMatrix<T,tmv::NonUnitDiag|tmv::ColMajor> l3(a1);
    tmv::LowerTriMatrix<T,tmv::UnitDiag|tmv::ColMajor> l4(a1);

    tmv::UpperTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::RowMajor> cu2(ca1);
    tmv::UpperTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::ColMajor> cu3(ca1);
    tmv::UpperTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::ColMajor> cu4(ca1);
    tmv::LowerTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::RowMajor> cl1(ca1);
    tmv::LowerTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::RowMajor> cl2(ca1);
    tmv::LowerTriMatrix<std::complex<T>,tmv::NonUnitDiag|tmv::ColMajor> cl3(ca1);
    tmv::LowerTriMatrix<std::complex<T>,tmv::UnitDiag|tmv::ColMajor> cl4(ca1);

    tmv::UpperTriMatrixView<T> u2v = u2.view();
    tmv::UpperTriMatrixView<T> u3v = u3.view();
    tmv::UpperTriMatrixView<T> u4v = u4.view();
    tmv::LowerTriMatrixView<T> l1v = l1.view();
    tmv::LowerTriMatrixView<T> l2v = l2.view();
    tmv::LowerTriMatrixView<T> l3v = l3.view();
    tmv::LowerTriMatrixView<T> l4v = l4.view();
    tmv::UpperTriMatrixView<std::complex<T> > cu2v = cu2.view();
    tmv::UpperTriMatrixView<std::complex<T> > cu3v = cu3.view();
    tmv::UpperTriMatrixView<std::complex<T> > cu4v = cu4.view();
    tmv::LowerTriMatrixView<std::complex<T> > cl1v = cl1.view();
    tmv::LowerTriMatrixView<std::complex<T> > cl2v = cl2.view();
    tmv::LowerTriMatrixView<std::complex<T> > cl3v = cl3.view();
    tmv::LowerTriMatrixView<std::complex<T> > cl4v = cl4.view();
#endif

    for(size_t i=START;i<b.size();i++) {
        if (showstartdone) {
            std::cerr<<"Start loop "<<i<<std::endl;
            std::cerr<<"bi = "<<b[i]<<std::endl;
        }
        tmv::BandMatrixView<T> bi = b[i];
        tmv::BandMatrixView<std::complex<T> > cbi = cb[i];

        TestMatrixArith4(bi,cbi,u1v,cu1v,"Band/UpperTri");
        TestMatrixArith5(bi,cbi,u1v,cu1v,"Band/UpperTri");
        TestMatrixArith6x(bi,cbi,u1v,cu1v,"Band/UpperTri");
#if (XTEST & 2)
        TestMatrixArith4(bi,cbi,l1v,cl1v,"Band/LowerTri");
        TestMatrixArith5(bi,cbi,l1v,cl1v,"Band/LowerTri");
        TestMatrixArith6x(bi,cbi,l1v,cl1v,"Band/LowerTri");
        TestMatrixArith4(bi,cbi,u2v,cu2v,"Band/UpperTri");
        TestMatrixArith5(bi,cbi,u2v,cu2v,"Band/UpperTri");
        TestMatrixArith6x(bi,cbi,u2v,cu2v,"Band/UpperTri");
        TestMatrixArith4(bi,cbi,l2v,cl2v,"Band/LowerTri");
        TestMatrixArith5(bi,cbi,l2v,cl2v,"Band/LowerTri");
        TestMatrixArith6x(bi,cbi,l2v,cl2v,"Band/LowerTri");
        TestMatrixArith4(bi,cbi,u3v,cu3v,"Band/UpperTri");
        TestMatrixArith5(bi,cbi,u3v,cu3v,"Band/UpperTri");
        TestMatrixArith6x(bi,cbi,u3v,cu3v,"Band/UpperTri");
        TestMatrixArith4(bi,cbi,l3v,cl3v,"Band/LowerTri");
        TestMatrixArith5(bi,cbi,l3v,cl3v,"Band/LowerTri");
        TestMatrixArith6x(bi,cbi,l3v,cl3v,"Band/LowerTri");
        TestMatrixArith4(bi,cbi,u4v,cu4v,"Band/UpperTri");
        TestMatrixArith5(bi,cbi,u4v,cu4v,"Band/UpperTri");
        TestMatrixArith6x(bi,cbi,u4v,cu4v,"Band/UpperTri");
        TestMatrixArith4(bi,cbi,l4v,cl4v,"Band/LowerTri");
        TestMatrixArith5(bi,cbi,l4v,cl4v,"Band/LowerTri");
        TestMatrixArith6x(bi,cbi,l4v,cl4v,"Band/LowerTri");
#endif
    }
}
Ejemplo n.º 16
0
void display(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();
	gluLookAt(r*cos(c*du), h, r*sin(c*du), 0, 0, 0, 0, 3, 0); //head position;eye direction(0.0,0.0,0.0),original point;(0.0,1.0,0.0),head above direction¡£
	
	//cylinder a(1, 15, 0, 90, 0, 0, 5, 0); //r,h,xangle yangle zangle, module position(xx yy zz)
	//sphere b(3, 100, 100, 0, 0, 0, 0, 2.5, 0); //r,xangle yangle zangle, module position(xx yy zz)
	//cube c(5, 10, 0, 0, 1, 1, 1); //length xangle yangle zangle, module position(xx yy zz)
	//rectangularpyramid d(4, 0, 0, 0, 0, 2, 0); //length xangle yangle zangle, module position(xx yy zz)
	//triangularpyramid f(2, 0, 0, 0, 8, 8, 8);//length xangle yangle zangle, module position(xx yy zz)						
	//f.draw();
	sphere sp(3, 100, 100, 0, 0, -2, 0, 8, 0);
	cylinder cy(3, 5, 0, 90, 0, -3, 9, -10);
	cube cu(3, 0, 0, 0, 0, 8, 10);
	triangularpyramid tr(2, 0, 0, 0, 0, -6, 8);
	rectangularpyramid rec(2, 0, 0, 0, 0, -6, -8);

	cylinder k1(0.3, 2, 90, 0, 0, 0, 0, 0);
	cylinder k2(0.3, 2, -90, 0, 0, 0, 0, 0);
	cylinder k3(0.3, 2, -45, 0, 0, 0, 0, 0);
	cylinder k4(0.3, 2.5, 45, 0, 0, 0, 0, 0);

	cylinder u1(0.3, 2, 90, 0, 0, 0, 0, 3);
	cylinder u2(0.3, 1.5, -90, 0, 0, 0, 0, 3);
	cylinder u3(0.3, 2, 0, 0, 0, 0, -1.8, 3);
	cylinder u4(0.3, 2, 90, 0, 0, 0, 0, 5);
	cylinder u5(0.3, 1.5, -90, 0, 0, 0, 0, 5);  

	cylinder g1(0.3, 2, -90, 0, 0, 0, -0.5, 6.4);
	cylinder g2(0.3, 1.5, -90, 0, 0, 0, -0.5, 6.4);
	cylinder g3(0.3, 2, 0, 0, 0, 0, -0.3, 6.4);
	cylinder g4(0.3, 2, 0, 0, 0, 0, 1.3, 6.4);
	cylinder g5(0.3, 2, 90, 0, 0, 0, 0, 8.4);
	cylinder g6(0.3, 1.5, -90, 0, 0, 0, 0, 8.4);
	cylinder g7(0.3, 2, 0, 0, 0, 0, -1.8, 6.4);

	cylinder e1(0.3, 1.8, -90, 0, 0, 0, -0.2, 10);
	cylinder e2(0.3, 1.8, 90, 0, 0, 0, -0.2, 10);
	cylinder e3(0.3, 2, 0, 0, 0, 0, -0.3, 10);
	cylinder e4(0.3, 2, 0, 0, 0, 0, 1.3, 10);
	cylinder e5(0.3, 2, 0, 0, 0, 0, -1.8, 10);

	cylinder r1(0.3, 1.8, -90, 0, 0, 0, -0.2, 13.5);
	cylinder r2(0.3, 1.8, 90, 0, 0, 0, -0.2, 13.5);
	cylinder r3(0.3, 2, 0, 0, 0, 0, -0.3, 13.5);
	cylinder r4(0.3, 1.2, 0, 0, 0, 0, 1.3, 13.5);
	cylinder r5(0.3, 1.7, 60, 0, 0, 0, 1.3, 14.5);
	cylinder r6(0.3, 2.5, 45, 0, 0, 0, 0, 13.5);


	cylinder c1(0.3, 2, 90, 0, 0, 0, 0, -15);
	cylinder c2(0.3, 2, -90, 0, 0, 0, 0, -15); 
	cylinder c3(0.3, 3, 0, 0, 0, 0, -1.8, -15);
	cylinder c4(0.3, 3, 0, 0, 0, 0, 1.8, -15);

	cylinder plus1(0.3,3.5, 0, 0, 0, 0, 0, -11);
	cylinder plus2(0.3, 4, 90, 0, 0, 0, 2, -9.2);
	cylinder plus3(0.3, 3.5, 0, 0, 0, 0, 0, -6);
	cylinder plus4(0.3, 4, 90, 0, 0, 0, 2, -4.2);
	cy.draw();
	sp.draw();
	cu.draw();
	tr.draw();
	rec.draw();

	k1.draw();
	k2.draw();
	k3.draw();
	k4.draw();

	u1.draw();
	u2.draw();
	u3.draw();
	u4.draw();
	u5.draw();
	
	g1.draw();
	g2.draw();
	g3.draw();
	g4.draw();
	g5.draw();
	g6.draw();
	g7.draw();

	e1.draw();
	e2.draw();
	e3.draw();
	e4.draw();
	e5.draw();

	r1.draw();
	r2.draw();
	r3.draw();
	r4.draw();
	r5.draw();
	r6.draw();

	c1.draw();
	c2.draw();
	c3.draw();
	c4.draw();
	
	plus1.draw();
	plus2.draw();
	plus3.draw();
	plus4.draw();

	glFlush();
	
}
Ejemplo n.º 17
0
	void testParse1() {

		// Test some valid constructions
		vmime::utility::url u1("", "");

		VASSERT_EQ("1.1", true, parseHelper(u1, "protocol://*****:*****@host:12345/path/"));
		VASSERT_EQ("1.2", "protocol", u1.getProtocol());
		VASSERT_EQ("1.3", "user", u1.getUsername());
		VASSERT_EQ("1.4", "password", u1.getPassword());
		VASSERT_EQ("1.5", "host", u1.getHost());
		VASSERT_EQ("1.6", 12345, u1.getPort());
		VASSERT_EQ("1.7", "/path/", u1.getPath());

		vmime::utility::url u2("", "");

		VASSERT_EQ("2.1", true, parseHelper(u2, "protocol://user@host:12345/path/"));
		VASSERT_EQ("2.2", "protocol", u2.getProtocol());
		VASSERT_EQ("2.3", "user", u2.getUsername());
		VASSERT_EQ("2.4", "", u2.getPassword());
		VASSERT_EQ("2.5", "host", u2.getHost());
		VASSERT_EQ("2.6", 12345, u2.getPort());
		VASSERT_EQ("2.7", "/path/", u2.getPath());

		vmime::utility::url u3("", "");

		VASSERT_EQ("3.1", true, parseHelper(u3, "protocol://host:12345/path/"));
		VASSERT_EQ("3.2", "protocol", u3.getProtocol());
		VASSERT_EQ("3.3", "", u3.getUsername());
		VASSERT_EQ("3.4", "", u3.getPassword());
		VASSERT_EQ("3.5", "host", u3.getHost());
		VASSERT_EQ("3.6", 12345, u3.getPort());
		VASSERT_EQ("3.7", "/path/", u3.getPath());

		vmime::utility::url u4("", "");

		VASSERT_EQ("4.1", true, parseHelper(u4, "protocol://host/path/"));
		VASSERT_EQ("4.2", "protocol", u4.getProtocol());
		VASSERT_EQ("4.3", "", u4.getUsername());
		VASSERT_EQ("4.4", "", u4.getPassword());
		VASSERT_EQ("4.5", "host", u4.getHost());
		VASSERT_EQ("4.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort());
		VASSERT_EQ("4.7", "/path/", u4.getPath());

		vmime::utility::url u5("", "");

		VASSERT_EQ("5.1", true, parseHelper(u5, "protocol://host/"));
		VASSERT_EQ("5.2", "protocol", u5.getProtocol());
		VASSERT_EQ("5.3", "", u5.getUsername());
		VASSERT_EQ("5.4", "", u5.getPassword());
		VASSERT_EQ("5.5", "host", u5.getHost());
		VASSERT_EQ("5.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort());
		VASSERT_EQ("5.7", "", u5.getPath());

		vmime::utility::url u6("", "");

		VASSERT_EQ("6.1", true, parseHelper(u4, "protocol://host/path/file"));
		VASSERT_EQ("6.2", "protocol", u4.getProtocol());
		VASSERT_EQ("6.3", "", u4.getUsername());
		VASSERT_EQ("6.4", "", u4.getPassword());
		VASSERT_EQ("6.5", "host", u4.getHost());
		VASSERT_EQ("6.6", vmime::utility::url::UNSPECIFIED_PORT, u4.getPort());
		VASSERT_EQ("6.7", "/path/file", u4.getPath());
	}