Beispiel #1
0
/*======== struct matrix * make_translate() ==========
Inputs:  int x
         int y
         int z 
Returns: The translation matrix created using x, y and z 
as the translation offsets.
====================*/
struct matrix * make_translate(double x, double y, double z) {

  struct matrix * m = new_matrix(4, 4);
  ident(m);

  m->m[0][3] = x;
  m->m[1][3] = y;
  m->m[2][3] = z;

  return m;
}
Beispiel #2
0
/*======== struct matrix * make_rotX() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and X as the axis of rotation.
====================*/
struct matrix * make_rotX(double theta) {
//printf("theta = %lf\n",theta);
  struct matrix * m = new_matrix(4, 4);
  ident(m);

  m->m[1][1] = cos( theta );
  m->m[1][2] = -1 *  sin( theta );
  m->m[2][1] = sin( theta );
  m->m[2][2] = cos( theta );
  return m;
}
Beispiel #3
0
/*======== struct matrix * make_rotZ() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and Z as the axis of rotation.
====================*/
struct matrix * make_rotZ(double theta) {
  struct matrix *transform = new_matrix(4, 4);

  ident(transform);
  transform->m[0][0] = cos(convertToRadians(theta));
  transform->m[0][1] = -1 * sin(convertToRadians(theta));
  transform->m[1][1] = cos(convertToRadians(theta));
  transform->m[1][0] = sin(convertToRadians(theta));

  return transform;
}
Beispiel #4
0
/*======== struct matrix * make_rotY() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and Y as the axis of rotation.
====================*/
struct matrix * make_rotY(double theta) {

  double deg = (theta * M_PI) / 180;
  struct matrix *y = new_matrix(4,4);
  ident(y);
  y->m[0][0] = cos(deg);
  y->m[0][2] = -sin(deg);
  y->m[2][0] = sin(deg);
  y->m[2][2] = cos(deg);
  return y;
}
Beispiel #5
0
/*======== struct matrix * make_rotZ() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and Z as the axis of rotation.
====================*/
struct matrix * make_rotZ(double theta) {

   double deg = (theta * M_PI) / 180;
  struct matrix *z = new_matrix(4,4);
  ident(z);
  z->m[0][0] = cos(deg);
  z->m[0][1] = -sin(deg);
  z->m[1][0] = sin(deg);
  z->m[1][1] = cos(deg);
  return z;
}
Beispiel #6
0
/*======== struct matrix * make_rotX() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and X as the axis of rotation.
====================*/
struct matrix * make_rotX(double theta) {

  struct matrix * m = new_matrix(4, 4);
  ident(m);

  m->m[1][1] = cos( theta );
  m->m[1][2] = -1 *  sin( theta );
  m->m[2][1] = sin( theta );
  m->m[2][2] = cos( theta );
  return m;
}
Beispiel #7
0
/*======== struct matrix * make_scale() ==========
Inputs:  int x
         int y
         int z 
Returns: The translation matrix creates using x, y and z
as the scale factors
====================*/
struct matrix * make_scale(double x, double y, double z) {

  struct matrix * m = new_matrix(4, 4);
  ident(m);

  m->m[0][0] = x;
  m->m[1][1] = y;
  m->m[2][2] = z;

  return m;
}
Beispiel #8
0
int main() {
	char resp = 'h';
	int num = 0;
	
	printf("Se desejar arvore aleatoria digite 'a'\nCaso contrário digite outra letra\n");
	scanf("%c",&resp);
	
	NO *raiz = NULL; 
	if(resp == 'a'){
		printf("Qual o numero de NOs desejados, além da raiz?\n");
		scanf("%i",&num);
		
		criar_abb_aleatorio(&raiz, num);
		
		printf("Árvore ANTES da exclusao:\n\n");
		ident(raiz, 0);
		
		printf("Qual nivel deve ser excluído?\n");
		scanf("%i",&num);
		excluirNivel(&raiz, num);

		printf("Árvore APOS da exclusao:\n\n");
		ident(raiz, 0);
	}
	else{
		printf("Use -1 para raiz sem filhos, 0  para raiz com um filho,\n1 para raiz com dois filhos, qualquer outro numero irá gerar arvore geral\nQue contém todos os casos\n");
		scanf("%i",&num);
		criar_abb(&raiz, num);

		printf("Árvore ANTES da exclusao:\n\n");
		ident(raiz, 0);

		printf("Qual nivel deve ser excluído?\n");
		scanf("%i",&num);
		excluirNivel(&raiz, num);

		printf("Árvore APOS da exclusao:\n\n");
		ident(raiz, 0);
		
	}
}
Beispiel #9
0
/*======== struct matrix * make_rotZ() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and Z as the axis of rotation.
====================*/
struct matrix * make_rotZ(double theta) {
  struct matrix * n = new_matrix(4,4);
  double s, c;
  ident(n);
  s = sin(theta*M_PI/180);
  c = cos(theta*M_PI/180);
  n->m[0][0] = c;
  n->m[0][1] = s*-1;
  n->m[1][0] = s;
  n->m[1][1] = c;
  return n;
}
Beispiel #10
0
    RocksEngine::RocksEngine(const std::string& path, bool durable)
        : _path(path), _durable(durable) {
        {  // create block cache
            uint64_t cacheSizeGB = 0;
            ProcessInfo pi;
            unsigned long long memSizeMB = pi.getMemSizeMB();
            if (memSizeMB > 0) {
                double cacheMB = memSizeMB / 2;
                cacheSizeGB = static_cast<uint64_t>(cacheMB / 1024);
            }
            if (cacheSizeGB < 1) {
                cacheSizeGB = 1;
            }
            _block_cache = rocksdb::NewLRUCache(cacheSizeGB * 1024 * 1024 * 1024LL);
        }
        // open DB
        rocksdb::DB* db;
        auto s = rocksdb::DB::Open(_options(), path, &db);
        ROCKS_STATUS_OK(s);
        _db.reset(db);

        // open iterator
        boost::scoped_ptr<rocksdb::Iterator> _iter(_db->NewIterator(rocksdb::ReadOptions()));

        // find maxPrefix
        _maxPrefix = 0;
        _iter->SeekToLast();
        if (_iter->Valid()) {
            // otherwise the DB is empty, so we just keep it at 0
            bool ok = extractPrefix(_iter->key(), &_maxPrefix);
            // this is DB corruption here
            invariant(ok);
        }

        // load ident to prefix map
        {
            boost::mutex::scoped_lock lk(_identPrefixMapMutex);
            for (_iter->Seek(kMetadataPrefix);
                 _iter->Valid() && _iter->key().starts_with(kMetadataPrefix); _iter->Next()) {
                rocksdb::Slice ident(_iter->key());
                ident.remove_prefix(kMetadataPrefix.size());
                // this could throw DBException, which then means DB corruption. We just let it fly
                // to the caller
                BSONObj identConfig(_iter->value().data());
                BSONElement element = identConfig.getField("prefix");
                // TODO: SERVER-16979 Correctly handle errors returned by RocksDB
                // This is DB corruption
                invariant(!element.eoo() || !element.isNumber());
                uint32_t identPrefix = static_cast<uint32_t>(element.numberInt());
                _identPrefixMap[StringData(ident.data(), ident.size())] = identPrefix;
            }
        }
    }
Beispiel #11
0
/*======== struct matrix * make_translate() ==========
Inputs: int x
int y
int z
Returns: The translation matrix created using x, y and z
as the translation offsets.
====================*/
struct matrix * make_translate(double x, double y, double z) {
    struct matrix * g;
    g = new_matrix(4,4);
    ident(g);

    g->m[0][3] = x;
    g->m[1][3] = y;
    g->m[2][3] = z;

    return g;

}
Beispiel #12
0
/*======== struct matrix * make_rotZ() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and Z as the axis of rotation.
====================*/
struct matrix * make_rotZ(double theta) {
  double rtheta = (M_PI/180)* theta; //converted to radians
  struct matrix *rot= new_matrix(4,4); 
  ident(rot); 

  rot->m[0][0] = cos(rtheta); 
  rot->m[0][1] = -sin(rtheta); 
  rot ->m[1][0] = sin(rtheta); 
  rot->m[1][1] = cos(rtheta); 

  return rot; 
}
Beispiel #13
0
/*======== struct matrix * make_rotZ() ==========
Inputs: double theta

Returns: The rotation matrix created using theta as the
angle of rotation and Z as the axis of rotation.
====================*/
struct matrix * make_rotZ(double theta) {
    struct matrix * g;
    g = new_matrix(4,4);
    ident(g);

    g->m[0][0] = cos((M_PI * theta) / 180);
    g->m[0][1] = -1 * sin((M_PI * theta) / 180 );
    g->m[1][0] = sin((M_PI * theta) / 180);
    g->m[1][1] = cos((M_PI * theta) / 180);

    return g;
}
Beispiel #14
0
/*======== struct matrix * make_translate() ==========
Inputs:  int x
         int y
         int z 
Returns: The translation matrix created using x, y and z 
as the translation offsets.
====================*/
struct matrix * make_translate(double x, double y, double z) {

  struct matrix *translate = new_matrix(4, 4); 

  ident(translate); 
  translate->m[0][3] = x;
  translate->m[1][3] = y; 
  translate->m[2][3] = z; 
  
  return translate; 

}
Beispiel #15
0
 void decodeTypeFunction() // 33
 {
     uint32_t result = decodeId();
     uint32_t return_type = decodeId();
     std::cout << ident() << "TypeFunction " << result << " " << return_type << " (";
     while(offset + 1 < length)
     {
         uint32_t paremeter_type = decodeId();
         std::cout << " " << paremeter_type;
     }
     std::cout << ")" << std::endl;
 }
Beispiel #16
0
/*======== struct matrix * make_rotZ() ==========
 Inputs:  double theta
 
 Returns: The rotation matrix created using theta as the
 angle of rotation and Z as the axis of rotation.
 ====================*/
struct matrix * make_rotZ(double theta) {
    double ntheta = (M_PI * theta) / 180.0;
    struct matrix *m;
    m = new_matrix(4, 4);
    ident(m);
    m->m[0][0] = cos(ntheta);
    m->m[0][1] = -1 * (sin(ntheta));
    m->m[1][0] = sin(ntheta);
    m->m[1][1] = cos(ntheta);
    
    return m;
}
Beispiel #17
0
/* analisa e traduz um fator matemático */
void factor(){
        if (look == '(') {
        
                match('(');
                expression();
                match(')');

        } else if(isalpha(look))
                ident();
        else
                emit("MOV AX, %c", getNum());
}
Beispiel #18
0
// recode/clone:
//
// Special-purpose constructor for keychain synchronization.  Copies an
// existing keychain but uses the operational keys from secretsBlob.  The 
// new KeychainDatabase will silently replace the existing KeychainDatabase
// as soon as the client declares that re-encoding of all keychain items is
// finished.  This is a little perilous since it allows a client to dictate
// securityd state, but we try to ensure that only the client that started 
// the re-encoding can declare it done.  
//
KeychainDatabase::KeychainDatabase(KeychainDatabase &src, Process &proc, DbHandle dbToClone)
	: LocalDatabase(proc), mValidData(false), mSecret(Allocator::standard(Allocator::sensitive)), mSaveSecret(false), version(0), mBlob(NULL)
{
	mCred = DataWalkers::copy(src.mCred, Allocator::standard());

	// Give this KeychainDatabase a temporary name
	std::string newDbName = std::string("////") + std::string(src.identifier().dbName());
	DLDbIdentifier newDLDbIdent(src.identifier().dlDbIdentifier().ssuid(), newDbName.c_str(), src.identifier().dlDbIdentifier().dbLocation());
	DbIdentifier ident(newDLDbIdent, src.identifier());

    // create common block and initialize
	RefPointer<KeychainDbCommon> newCommon = new KeychainDbCommon(proc.session(), ident);
	StLock<Mutex> _(*newCommon);
	parent(*newCommon);

	// set initial database parameters from the source keychain
	common().mParams = src.common().mParams;
	
	// establish the source keychain's master secret as ours
	// @@@  NB: this is a v. 0.1 assumption.  We *should* trigger new UI 
	//      that offers the user the option of using the existing password 
	//      or choosing a new one.  That would require a new 
	//      SecurityAgentQuery type, new UI, and--possibly--modifications to
	//      ensure that the new password is available here to generate the 
	//      new master secret.  
	src.unlockDb();		// precaution for masterKey()
	common().setup(src.blob(), src.common().masterKey());
	
    // import the operational secrets
	RefPointer<KeychainDatabase> srcKC = Server::keychain(dbToClone);
	common().importSecrets(srcKC->common());
	
	// import source keychain's ACL  
	CssmData pubAcl, privAcl;
	src.acl().exportBlob(pubAcl, privAcl);
	importBlob(pubAcl.data(), privAcl.data());
	src.acl().allocator.free(pubAcl);
	src.acl().allocator.free(privAcl);
	
	// indicate that this keychain should be allowed to do some otherwise
	// risky things required for copying, like re-encoding keys
	mRecodingSource = &src;
	
	common().setUnlocked();
	mValidData = true;
	
    encode();

	proc.addReference(*this);
	secdebug("SSdb", "database %s(%p) created as copy, common at %p",
			 common().dbName(), this, &common());
}
Beispiel #19
0
void 	CXmlOutPro::prtl_ident(PSTR fmt,...)
{
	ident();

    va_list argptr;
	char buf[280];

    va_start(argptr, fmt);
    vsprintf(buf, fmt, argptr);
    va_end(argptr);

	prtl("%s",buf);
}
Beispiel #20
0
int ident_dir(char *fn)
{
   int count,i = 0;
   struct dirent **files;
   int file_select = NULL;
   count = scandir(fn, &files, file_select, alphasort);
   if (count > 0) {
      for (i = 0; i < count; ++i) {
         ident(files[i]->d_name);
      }
   }
   return 0;
}
Beispiel #21
0
    void decodeCompositeConstruct() // 80
    {
        uint32_t result_type = decodeId();
        uint32_t result = decodeId();
        std::cout << ident() << "CompositeConstruct " << types.at(result_type) << " " << result;

        while(offset + 1 < length)
        {
            uint32_t constituent = decodeId();
            std::cout << " " << constituent;
        }
        std::cout << std::endl;
    }
Beispiel #22
0
EncodedJSValue JIT_OPERATION operationIn(ExecState* exec, JSCell* base, StringImpl* key)
{
    VM* vm = &exec->vm();
    NativeCallFrameTracer tracer(vm, exec);

    if (!base->isObject()) {
        vm->throwException(exec, createInvalidParameterError(exec, "in", base));
        return JSValue::encode(jsUndefined());
    }

    Identifier ident(vm, key);
    return JSValue::encode(jsBoolean(asObject(base)->hasProperty(exec, ident)));
}
Beispiel #23
0
/*======== struct matrix * make_rotX() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the 
angle of rotation and X as the axis of rotation.
====================*/
struct matrix * make_rotX(double theta) {
  theta = M_PI* (theta/180); //converted to radians
  //printf("%lf\n", theta); 
  struct matrix *rot= new_matrix(4,4); 
  ident(rot); 

  rot->m[1][1] = cos(theta); 
  rot->m[1][2] = -sin(theta); 
  rot ->m[2][1] = sin(theta); 
  rot->m[2][2] = cos(theta); 

  return rot; 
}
Beispiel #24
0
/*** Função que confere um procedimento ***/
int procedimento() {
    if(match(PROCEDURE)) {
        if(ident()) {
            if(parametros()) {
                if(declaracao()) {
                    if(bloco()) {
                        return 1;
                    } else return 0;
                } else return 0;
            } else return 0;
        } else return 0;
    } else return 0;
}
Beispiel #25
0
void
RotationMatrixTest::rotVtoU(RealVectorValue v, RealVectorValue u)
{
  RealTensorValue ident(1,0,0,  0,1,0,  0,0,1);
  RealVectorValue vhat = v/v.size();
  RealVectorValue uhat = u/u.size();
  RealTensorValue r = RotationMatrix::rotVec1ToVec2(v, u);
  RealVectorValue rotated_v = r*vhat;
  for (unsigned i = 0 ; i < LIBMESH_DIM ; ++i)
    CPPUNIT_ASSERT_DOUBLES_EQUAL( rotated_v(i), uhat(i), 0.0001);
  CPPUNIT_ASSERT( r*r.transpose() == ident);
  CPPUNIT_ASSERT( r.transpose()*r == ident);
}
Beispiel #26
0
/*** Função que confere a lista de constantes ***/
int lista_constantes() {
    if(ident()) {
        if(match(EQUAL)) {
            if(inteiro()) {
                if(match(VIRGULA)) {
                    if(lista_constantes()) {
                        return 1;
                    } else return 0;
                } else return 1;
            } else return 0;
        } else return 0;
    } else return 0;
}
Beispiel #27
0
/*======== struct matrix * make_rotZ() ==========
Inputs:  double theta

Returns: The rotation matrix created using theta as the
angle of rotation and Z as the axis of rotation.
====================*/
struct matrix * make_rotZ(double theta) {
    struct matrix * m = new_matrix(4, 4);
    ident(m);

    double r_theta = theta * M_PI / 180.0;

    m->m[0][0] = cos(r_theta);
    m->m[0][1] = -1 * sin(r_theta);
    m->m[1][0] = sin(r_theta);
    m->m[1][1] = cos(r_theta);

    return m;
}
Beispiel #28
0
TEST(CSSTokenizerTest, StringToken)
{
    TEST_TOKENS("'text'", string("text"));
    TEST_TOKENS("\"text\"", string("text"));
    TEST_TOKENS("'testing, 123!'", string("testing, 123!"));
    TEST_TOKENS("'es\\'ca\\\"pe'", string("es'ca\"pe"));
    TEST_TOKENS("'\"quotes\"'", string("\"quotes\""));
    TEST_TOKENS("\"'quotes'\"", string("'quotes'"));
    TEST_TOKENS("\"mismatch'", string("mismatch'"));
    TEST_TOKENS("'text\5\t\13'", string("text\5\t\13"));
    TEST_TOKENS("\"end on eof", string("end on eof"));
    TEST_TOKENS("'esca\\\nped'", string("escaped"));
    TEST_TOKENS("\"esc\\\faped\"", string("escaped"));
    TEST_TOKENS("'new\\\rline'", string("newline"));
    TEST_TOKENS("\"new\\\r\nline\"", string("newline"));
    TEST_TOKENS("'bad\nstring", badString, whitespace, ident("string"));
    TEST_TOKENS("'bad\rstring", badString, whitespace, ident("string"));
    TEST_TOKENS("'bad\r\nstring", badString, whitespace, ident("string"));
    TEST_TOKENS("'bad\fstring", badString, whitespace, ident("string"));
    // FIXME: Preprocessing is supposed to replace U+0000 with U+FFFD
    // TEST_TOKENS("'\0'", string(fromUChar32(0xFFFD)));
}
Beispiel #29
0
TextureFactoryIdentifier
BasicCompositor::GetTextureFactoryIdentifier()
{
  TextureFactoryIdentifier ident(LayersBackend::LAYERS_BASIC,
                                 XRE_GetProcessType(),
                                 GetMaxTextureSize());

  // All composition ops are supported in software.
  for (uint8_t op = 0; op < uint8_t(CompositionOp::OP_COUNT); op++) {
    ident.mSupportedBlendModes += CompositionOp(op);
  }
  return ident;
}
Beispiel #30
0
std::shared_ptr<Font> ResourceManager::font(const Arx::String &path, TextureBlock * tb) {
    Arx::File tmp(path);
    Arx::String extensionedPath = tmp.withExtension(".ttf").path;

    auto apath = adjustedPath(path);
    if (!apath.exists()) {
        apath = adjustedPath(fmt("fonts/{}",extensionedPath));
    }

    PathAndTexture ident(apath.path,tb);
    return ResourceManager::inst().fonts.getOrElseUpdate(ident,[&](){ return Font::fromFile(apath,tb); });

}