Example #1
0
static int dc_add_altitude()
{
	HKEY hkey1 = NULL;
	HKEY hkey2 = NULL;
	int  succs = 0;
	u32  flags = 0;

	if (RegCreateKey(
		HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\dcrypt\\Instances", &hkey1) != 0) 
	{
		goto exit;
	}
	if (RegSetValueEx(hkey1, L"DefaultInstance", 0, REG_SZ, pv(L"dcrypt"), sizeof(L"dcrypt")) != 0) {
		goto exit;
	}
	if (RegCreateKey(hkey1, L"dcrypt", &hkey2) != 0) {
		goto exit;
	}
	if (RegSetValueEx(hkey2, L"Altitude", 0, REG_SZ, pv(L"87150"), sizeof(L"87150")) != 0) {
		goto exit;
	}
	succs = RegSetValueEx(hkey2, L"Flags", 0, REG_DWORD, pv(&flags), sizeof(flags)) == 0;

	if (hkey2 != NULL) RegCloseKey(hkey2);
	if (hkey1 != NULL) RegCloseKey(hkey1);
exit:
	return succs != 0 ? ST_OK : ST_REG_ERROR;
}
inline bool go()
{
    k=0;
    p[k].resize(0);
    p[k].push_back(pv(-inf,inf));
    p[k].push_back(pv(-inf,-inf));
    p[k].push_back(pv(inf,-inf));
    p[k].push_back(pv(inf,inf));
    for(i=0;i<n;++i)
    {
        get(pnt[i],pnt[(i+1)%n],a,b,c);
        c+=the*sqrt(a*a+b*b);
        p[!k].resize(0);
        for(l=0;l<p[k].size();++l)
            if(a*p[k][l].x+b*p[k][l].y+c<eps)
                p[!k].push_back(p[k][l]);
            else
            {
                m=(l+p[k].size()-1)%p[k].size();
                if(a*p[k][m].x+b*p[k][m].y+c<-eps)
                    p[!k].push_back(ins(p[k][m],p[k][l]));
                m=(l+1)%p[k].size();
                if(a*p[k][m].x+b*p[k][m].y+c<-eps)
                    p[!k].push_back(ins(p[k][m],p[k][l]));
            }
        k=!k;
        if(p[k].empty())
            break;
    }
    //`结果在p[k]中`
    return p[k].empty();
}
int main(int argc, char *argv[])
{
	int sem_id = semget(IPC_PRIVATE, 1, 0666);

        union semun sem_un;
        sem_un.val = 1;
        semctl(sem_id, 0, SETVAL, sem_un);

        pid_t pid = fork();
        if (pid < 0) {
                return 1;
        } else if (pid == 0) {
                printf("Child try to get binary sem\n");
                pv(sem_id, -1);
                printf("Child get the sem and would release it after 5 seconds\n");
                sleep(5);
                pv(sem_id, 1);
                exit(0);
        } else {
                printf("Parent try to get binary sem\n");
                pv(sem_id, -1);
                printf("Parent get the sem and would release it after 5 seconds\n");
                sleep(5);
                pv(sem_id, 1);
        }

        waitpid(pid, NULL, 0);
        semctl(sem_id, 0, IPC_RMID, sem_un);

	return EXIT_SUCCESS;
}
Example #4
0
static int dc_is_this_ssd(dev_hook *hook)
{
	STORAGE_PROPERTY_QUERY         query = { StorageDeviceSeekPenaltyProperty,  PropertyStandardQuery };
	DEVICE_SEEK_PENALTY_DESCRIPTOR seek  = {0};
	char                           buff[sizeof(ATA_PASS_THROUGH_EX) + sizeof(IDENTIFY_DEVICE_DATA)] = {0};
    PATA_PASS_THROUGH_EX           pata = pv(buff);
	PIDENTIFY_DEVICE_DATA          idat = pv(buff + sizeof(ATA_PASS_THROUGH_EX));
	int                            resl;

	resl = io_hook_ioctl(hook, IOCTL_STORAGE_QUERY_PROPERTY, &query, sizeof(query), &seek, sizeof(seek));

	if ( (resl == ST_OK) && (seek.Version >= sizeof(seek)) && (seek.Size >= sizeof(seek)) ) {
		DbgMsg("seek.IncursSeekPenalty %d\n", seek.IncursSeekPenalty);
		return seek.IncursSeekPenalty == FALSE;
	}
	pata->Length             = sizeof(ATA_PASS_THROUGH_EX);
	pata->DataBufferOffset   = sizeof(ATA_PASS_THROUGH_EX);
	pata->DataTransferLength = sizeof(IDENTIFY_DEVICE_DATA);
	pata->AtaFlags           = ATA_FLAGS_DATA_IN;
	pata->TimeOutValue       = 2;
	pata->CurrentTaskFile[6] = IDE_COMMAND_IDENTIFY;

	if (io_hook_ioctl(hook, IOCTL_ATA_PASS_THROUGH, buff, sizeof(buff), buff, sizeof(buff)) != ST_OK) {
		return 0;
	} else {
		DbgMsg("idat->NominalMediaRotationRate %d\n", idat->NominalMediaRotationRate);
	}
	return idat->NominalMediaRotationRate == 1;
}
Example #5
0
Vector2d leastSquaresEstimate(vector<Vector2f> points,
                              Vector2f p0, Vector2f p3,
                              Vector2d d1, Vector2d d2)
{
    // hack up points
    if(points.size() <= 10)
        points = interpolatePoints(points);
    if(points.size() <= 20)
        points = interpolatePoints(points);

    qDebug() << "num points in arc" << points.size();
    int m = points.size()-2; // number of points to fit
    int n = 2;               // number of control points to find

    Eigen::MatrixXd Z(m, n);
    Eigen::MatrixXd Y(m, n);
    Eigen::VectorXd pu(m);
    Eigen::VectorXd pv(m);

    for(int i = 0; i < m; ++i)


    {
        int idx = i+1;
        Vector2f pt = points[idx];

        double t = double(idx)/(m-1);
        auto b0 = Bernstein3(0, t);
        auto b1 = Bernstein3(1, t);
        auto b2 = Bernstein3(2, t);
        auto b3 = Bernstein3(3, t);

        // Filling in the matrices
        Z(i, 0) = b1*d1[0];
        Z(i, 1) = b2*d2[0];

        Y(i, 0) = b1*d1[1];
        Y(i, 1) = b2*d2[1];

        auto pp = pt - p0*(b0 + b1) - p3*(b2 + b3);
        pu(i) = pp[0];
        pv(i) = pp[1];
    }

    auto Zt = Z.transpose();
    auto Yt = Y.transpose();
    auto A = Zt*Z+Yt*Y;

    auto rhs = Zt*pu+Yt*pv;
    Eigen::VectorXd ans = A.inverse()*rhs;

    auto s = makeVector2d(ans(0), ans(1));
    qDebug() << "least squares" << s[0] << s[1];
    s[0]=fabs(s[0])/**10*/;
    s[1]=fabs(s[1]);
    return s;
}
Example #6
0
static void boot_from_mbr(hdd_inf *hdd, int n_mount)
{
	if ( !(conf.options & OP_EXTERNAL) && (hdd->dos_numb == boot_dsk) ) {
		autocpy(pv(0x7C00), conf.save_mbr, SECTOR_SIZE);
	} else {
		dc_disk_io(hdd, pv(0x7C00), 1, 0, 1);
	}
	bios_jump_boot(hdd->dos_numb, n_mount);
}
void static_cast_test()
{
    {
        boost::shared_ptr<void> pv;

        boost::shared_ptr<int[]> pi = boost::static_pointer_cast<int[]>( pv );
        BOOST_TEST( pi.get() == 0 );

        boost::shared_ptr<int[3]> pi2 = boost::static_pointer_cast<int[3]>( pv );
        BOOST_TEST( pi2.get() == 0 );

        boost::shared_ptr<X[]> px = boost::static_pointer_cast<X[]>( pv );
        BOOST_TEST( px.get() == 0 );

        boost::shared_ptr<X[5]> px2 = boost::static_pointer_cast<X[5]>( pv );
        BOOST_TEST( px2.get() == 0 );
    }

    {
        boost::shared_ptr<int[]> pi( new int[2] );
        boost::shared_ptr<void> pv( pi );

        boost::shared_ptr<int[]> pi2 = boost::static_pointer_cast<int[]>( pv );
        BOOST_TEST(pi.get() == pi2.get());
        BOOST_TEST(!(pi < pi2 || pi2 < pi));

        boost::shared_ptr<int[2]> pi3 = boost::static_pointer_cast<int[2]>( pv );
        BOOST_TEST(pi.get() == pi3.get());
        BOOST_TEST(!(pi < pi3 || pi3 < pi));

        boost::shared_ptr<void> pv2( pi3 );

        boost::shared_ptr<int[]> pi4 = boost::static_pointer_cast<int[]>( pv2 );
        BOOST_TEST(pi.get() == pi4.get());
        BOOST_TEST(!(pi < pi4 || pi4 < pi));
    }

    {
        boost::shared_ptr<X[]> px( new X[4] );
        boost::shared_ptr<void> pv( px );

        boost::shared_ptr<X[]> px2 = boost::static_pointer_cast<X[]>( pv );
        BOOST_TEST(px.get() == px2.get());
        BOOST_TEST(!(px < px2 || px2 < px));

        boost::shared_ptr<X[4]> px3 = boost::static_pointer_cast<X[4]>( pv );
        BOOST_TEST(px.get() == px3.get());
        BOOST_TEST(!(px < px3 || px3 < px));

        boost::shared_ptr<void> pv2( px3 );

        boost::shared_ptr<X[]> px4 = boost::static_pointer_cast<X[]>( pv2 );
        BOOST_TEST(px.get() == px4.get());
        BOOST_TEST(!(px < px4 || px4 < px));
    }
}
Example #8
0
void gfs2_rindex_print(const struct gfs2_rindex_host *ri)
{
	printk(KERN_INFO "  ri_addr = %llu\n", (unsigned long long)ri->ri_addr);
	pv(ri, ri_length, "%u");

	printk(KERN_INFO "  ri_data0 = %llu\n", (unsigned long long)ri->ri_data0);
	pv(ri, ri_data, "%u");

	pv(ri, ri_bitbytes, "%u");
}
Example #9
0
void com_putchar(char ch) 
{
	if (ch == '\n') {
		com_putchar('\r');
	}

	while ((READ_PORT_UCHAR (pv(SER_LSR(COM_BASE))) & SR_LSR_TBE) == 0);

	WRITE_PORT_UCHAR(pv(SER_THR(COM_BASE)), ch);
}
Example #10
0
int dc_backup_header(wchar_t *dev_name, dc_pass *password, void *out)
{
	dc_header *header = NULL;
	xts_key   *hdr_key = NULL;
	dev_hook  *hook    = NULL;
	int        resl;
	s8         salt[PKCS5_SALT_SIZE];

	do
	{
		if ( (hook = dc_find_hook(dev_name)) == NULL ) {
			resl = ST_NF_DEVICE; break;
		}
		wait_object_infinity(&hook->busy_lock);

		if (hook->flags & (F_SYNC | F_UNSUPRT | F_DISABLE | F_CDROM)) {
			resl = ST_ERROR; break;
		}
		if ( (hdr_key = mm_alloc(sizeof(xts_key), MEM_SECURE)) == NULL ) {
			resl = ST_NOMEM; break;
		}
		/* get device params */
		if (hook->dsk_size == 0) {
			if ( (resl = dc_fill_disk_info(hook)) != ST_OK ) break;
		}
		if ( (resl = io_read_header(hook, &header, NULL, password)) != ST_OK ) {
			break;
		}
		/* generate new salt */
		cp_rand_bytes(header->salt, PKCS5_SALT_SIZE);
		/* save original salt */
		memcpy(salt, header->salt, PKCS5_SALT_SIZE);		
		/* init new header key */
		cp_set_header_key(hdr_key, header->salt, header->alg_1, password);		
		/* encrypt header with new key */
		xts_encrypt(pv(header), pv(header), sizeof(dc_header), 0, hdr_key);
		/* restore original salt */
		memcpy(header->salt, salt, PKCS5_SALT_SIZE);

		/* copy header to output */
		memcpy(out, header, sizeof(dc_header));
		resl = ST_OK;
	} while (0);

	if (hook != NULL) {
		KeReleaseMutex(&hook->busy_lock, FALSE);
		dc_deref_hook(hook);
	}
	/* prevent leaks */
	burn(salt, sizeof(salt));
	/* free memory */	
	if (header != NULL) mm_free(header);
	if (hdr_key != NULL) mm_free(hdr_key);
	return resl;
}
Example #11
0
// ****************************************************************************
void sigUser(int sig) {
    if (SIGUSR1 == sig) {
        pv("SIGUSR1 received\n");
    }
    else if (SIGUSR2 == sig) {
        pv("SIGUSR2 received\n");
    }
    else {
        err_dump("unkown sig: %d\n", sig);
    }
}
Example #12
0
int io_write_header(dev_hook *hook, dc_header *header, xts_key *hdr_key, dc_pass *password)
{
	u8         salt[PKCS5_SALT_SIZE];
	int        hdr_len = max(sizeof(dc_header), hook->bps);
	dc_header *hcopy = NULL;
	xts_key   *h_key = hdr_key;
	int        resl;

	do
	{
		if ( (hcopy = mm_alloc(hdr_len, MEM_SECURE | MEM_SUCCESS)) == NULL ) { resl = ST_NOMEM; break; }
		memcpy(hcopy, header, sizeof(dc_header));
		
		if (h_key == NULL) {
			if ( (h_key = mm_alloc(sizeof(xts_key), MEM_SECURE | MEM_SUCCESS)) == NULL ) { resl = ST_NOMEM; break; }
		}
		if (hdr_key == NULL)
		{
			/* add volume header to random pool because RNG not 
			   have sufficient entropy at boot time 
			*/
			cp_rand_add_seed(header, sizeof(dc_header));
			/* generate new salt */
			cp_rand_bytes(salt, PKCS5_SALT_SIZE);
			/* copy salt to header */
			memcpy(hcopy->salt, salt, PKCS5_SALT_SIZE);
			/* init new header key */
			cp_set_header_key(h_key, salt, header->alg_1, password);
		} else {
			/* save original salt */
			memcpy(salt, header->salt, PKCS5_SALT_SIZE);
		}
		/* calc header CRC */
		hcopy->hdr_crc = crc32(pv(&hcopy->version), DC_CRC_AREA_SIZE);
		/* encrypt header with new key */
		xts_encrypt(pv(hcopy), pv(hcopy), sizeof(dc_header), 0, h_key);
		/* restore original salt */
		memcpy(hcopy->salt, salt, PKCS5_SALT_SIZE);		
		
		/* fill the gap with random numbers */
		if (hdr_len > sizeof(dc_header)) {
			cp_rand_bytes(pv(hcopy + 1), hdr_len - sizeof(dc_header));
		}
		/* write new header */
		resl = io_hook_rw(hook, hcopy, hdr_len, 0, 0);
	} while (0);

	/* prevent leaks */
	burn(salt, sizeof(salt));
	/* free resources */
	if (h_key != NULL && h_key != hdr_key) mm_free(h_key);
	if (hcopy != NULL) mm_free(hcopy);	
	return resl;
}
Example #13
0
int main( int argc, char **argv )
{
    int retv = 0 ;
    
    char *p = NULL ;
    
    alloca2_init(1024) ;
    
    pv(p,alloca2_base) ;
    pv(p,alloca2_top) ;
    
    pv(p,p) ;
    
    /* grab alloca2's memory until we run out
     */
    
    int n = 0 ;
    
    do {
        p = alloca2(100) ;
        
        if( p != NULL )
            n++ ;
        
        pv(p,p) ;
        
        } while( p != NULL ) ;
    
    /* we ran out of (alloca2) memory to get here
     *
     * let's release some back and see what happens
     */
    
    alloca2_release( n * 100 ) ;
    
    do {
        p = alloca2(100) ;
        
        if( p != NULL )
            n++ ;
        
        pv(p,p) ;
        
        } while( p != NULL ) ;
    
    /* You should see that not all the memory could be
     * reused.  This is because of alignment issues as
     * alloca2 always keeps addresses aligned to
     * 16 bytes.
     */
    
    return retv ;
}
Example #14
0
static int dc_mount_parts()
{
	dc_header  *header  = pv(0x5000); /* free memory location */
	dc_key     *hdr_key = pv(0x5000 + sizeof(dc_header));
	list_entry *entry;
	prt_inf    *prt;
	int         n_mount;

	/* mount partitions on all disks */
	n_mount = 0;
	entry   = prt_head.flink;

	while ( (entry != &prt_head) && (n_mount < MAX_MOUNT) )
	{
		prt   = contain_record(entry, prt_inf, entry_glb);
		entry = entry->flink;

		do
		{
			/* read volume header */
			if (dc_partition_io(prt, header, DC_AREA_SECTORS, 0, 1) == 0) {					
				break;
			}

			if (dc_decrypt_header(hdr_key, header, &bd_dat->password) == 0) {
				break;
			}

			if (header->flags & VF_REENCRYPT) {
				prt->o_key.key_d = malloc(PKCS_DERIVE_MAX);
				autocpy(prt->o_key.key_d, header->key_2, PKCS_DERIVE_MAX);
			}

			prt->d_key.key_d = malloc(PKCS_DERIVE_MAX);
			autocpy(prt->d_key.key_d, header->key_1, PKCS_DERIVE_MAX);

			prt->flags     = header->flags;
			prt->tmp_size  = header->tmp_size / SECTOR_SIZE;
			prt->stor_off  = header->stor_off / SECTOR_SIZE;
			prt->disk_id   = header->disk_id; 
			prt->d_key.alg = header->alg_1;
			prt->o_key.alg = header->alg_2;
			prt->mnt_ok   = 1; n_mount++;
		} while (0);
	}

	/* prevent leaks */
	zeroauto(header,  sizeof(dc_header));
	zeroauto(hdr_key, sizeof(dc_key));

	return n_mount;
}
Example #15
0
/**
 * gfs2_sb_print2 - Print out a superblock
 * @sb: the cpu-order buffer
 */
static void gfs2_sb_print2(struct gfs2_sb *sbp2)
{
	gfs2_meta_header_print(&sbp2->sb_header);

	pv(sbp2, sb_fs_format, "%u", "0x%x");
	pv(sbp2, sb_multihost_format, "%u", "0x%x");

	if (sbd.gfs1)
		pv(sbd1, sb_flags, "%u", "0x%x");
	pv(sbp2, sb_bsize, "%u", "0x%x");
	pv(sbp2, sb_bsize_shift, "%u", "0x%x");
	if (sbd.gfs1) {
		pv(sbd1, sb_seg_size, "%u", "0x%x");
		gfs2_inum_print2("jindex ino", &sbd1->sb_jindex_di);
		gfs2_inum_print2("rindex ino", &sbd1->sb_rindex_di);
	}
	else
		gfs2_inum_print2("master dir", &sbp2->sb_master_dir);
	gfs2_inum_print2("root dir  ", &sbp2->sb_root_dir);

	pv(sbp2, sb_lockproto, "%s", NULL);
	pv(sbp2, sb_locktable, "%s", NULL);
	if (sbd.gfs1) {
		gfs2_inum_print2("quota ino ", &gfs1_quota_di);
		gfs2_inum_print2("license   ", &gfs1_license_di);
	}
#ifdef GFS2_HAS_UUID
	print_it("  sb_uuid", "%s", NULL, str_uuid(sbp2->sb_uuid));
#endif
}
Example #16
0
    line(double a,double b,double c) // a*x + b*y + c = 0
    {
#define maxl 1e2 //preciseness should not be too high ( compare with eps )
        if(fabs(b)>eps)
        {
            pnt[0]=pv(maxl,(c+a*maxl)/(-b));
            pnt[1]=pv(-maxl,(c-a*maxl)/(-b));
        }
        else
        {
            pnt[0]=pv(-c/a,maxl);
            pnt[1]=pv(-c/a,-maxl);
        }
#undef maxl
    }
Vector<double> AncillaryMethods::PlaneToWorld(const Camera& camera, const Vector<double>& plane_in_camera)
{
    Vector<double> pv(plane_in_camera(0), plane_in_camera(1), plane_in_camera(2));
    pv = camera.get_R() * pv;

    double d = plane_in_camera(3) - DotProduct(pv, camera.get_t());

    Vector<double> plane(4);
    plane(0) = pv(0)/pv.norm();
    plane(1) = pv(1)/pv.norm();
    plane(2) = pv(2)/pv.norm();
    plane(3) = d;

    return plane;
}
Example #18
0
 bool EdgeSE2PointXY::resolveCaches()
 {
   ParameterVector pv(1);
   pv[0] = _sensorOffset;
   resolveCache(_sensorCache, static_cast<OptimizableGraph::Vertex*>(_vertices[0]), "TUTORIAL_CACHE_SE2_OFFSET", pv);
   return _sensorCache != 0;
 }
Example #19
0
TEST(kdtree, DefaultConstructor)
{
    typedef double realScalarType;
    typedef point<realScalarType> pointType;
    typedef kdTree<pointType> kdTreeType;

    std::default_random_engine generator;

    std::normal_distribution<double> distribution(0.,1.0);

    const size_t numDims = 1;
    const size_t numPoints = 10;

    std::vector<pointType> pts(numPoints);


    for(size_t i=0;i<numPoints;++i)
    {
        std::vector<double> pv(numDims);
        for(size_t j=0;j<numDims;++j)
        {
            pv[j] = distribution(generator);
        }

        pointType pt(pv);

        pts[i] = pt;
    }

    kdTreeType kdtr(pts);
}
TEST(CLASSNAME(test_local_parameters, RMW_IMPLEMENTATION), to_string) {
  rclcpp::parameter::ParameterVariant pv("foo", "bar");
  rclcpp::parameter::ParameterVariant pv2("foo2", "bar2");
  std::string json_dict = std::to_string(pv);
  EXPECT_STREQ(
    "{\"name\": \"foo\", \"type\": \"string\", \"value\": \"bar\"}",
    json_dict.c_str());
  json_dict = rclcpp::parameter::_to_json_dict_entry(pv);
  EXPECT_STREQ(
    "\"foo\": {\"type\": \"string\", \"value\": \"bar\"}",
    json_dict.c_str());
  std::vector<rclcpp::parameter::ParameterVariant> vpv;
  vpv.push_back(pv);
  vpv.push_back(pv2);
  json_dict = std::to_string(vpv);
  EXPECT_STREQ(
    "{\"foo\": {\"type\": \"string\", \"value\": \"bar\"}, "
    "\"foo2\": {\"type\": \"string\", \"value\": \"bar2\"}}",
    json_dict.c_str());

  pv = rclcpp::parameter::ParameterVariant("foo", 2.1);
  // TODO(tfoote) convert the value to a float and use epsilon test.
  EXPECT_STREQ(
    "{\"name\": \"foo\", \"type\": \"double\", \"value\": \"2.100000\"}",
    std::to_string(pv).c_str());
  pv = rclcpp::parameter::ParameterVariant("foo", 8);
  EXPECT_STREQ(
    "{\"name\": \"foo\", \"type\": \"integer\", \"value\": \"8\"}",
    std::to_string(pv).c_str());
}
Example #21
0
DWORD 
WINAPI 
_thread_enc_iso_proc(
		LPVOID lparam
	)
{
	_dnode *node;
	dc_open_device( );

	if ( (node = pv(lparam)) != NULL )
	{
		node->dlg.rlt = ST_OK;

		node->dlg.rlt = dc_encrypt_cd(
			node->dlg.iso.s_iso_src, node->dlg.iso.s_iso_dst, node->dlg.iso.pass, node->dlg.iso.cipher_id, dc_cd_callback, lparam
			);
		{
			secure_free( node->dlg.iso.pass );
			SendMessage( GetParent(GetParent(node->dlg.h_page)), WM_CLOSE_DIALOG, 0, 0 );
		}

	}
	//EnterCriticalSection(&crit_sect);
	//LeaveCriticalSection(&crit_sect);

	dc_close_device( );
	return 1L;
}
Example #22
0
TEST_F(MeshLibProperties, AddDoublePropertiesTupleSize2)
{
    ASSERT_TRUE(mesh != nullptr);
    const std::size_t number_of_tuples(mesh_size*mesh_size*mesh_size);

    std::string const prop_name("TestProperty");
    boost::optional<MeshLib::PropertyVector<double> &> opt_pv(
        mesh->getProperties().createNewPropertyVector<double>(prop_name,
            MeshLib::MeshItemType::Cell, 2)
    );
    // PropertyVector should be created in a correct way
    ASSERT_TRUE(!(!opt_pv));

    MeshLib::PropertyVector<double> & pv(opt_pv.get());

    ASSERT_EQ(0u, pv.getPropertyName().compare(prop_name));
    ASSERT_EQ(MeshLib::MeshItemType::Cell, pv.getMeshItemType());
    ASSERT_EQ(2u, pv.getNumberOfComponents());
    ASSERT_EQ(0u, pv.getNumberOfTuples());
    ASSERT_EQ(0u, pv.size());

    // push some values (2 tuples) into the vector
    for (std::size_t k(0); k<number_of_tuples; k++) {
        pv.push_back(static_cast<double>(k));
        pv.push_back(static_cast<double>(k));
    }
    // check the number of tuples
    ASSERT_EQ(number_of_tuples, pv.getNumberOfTuples());
    ASSERT_EQ(pv.getNumberOfTuples()*pv.getNumberOfComponents(), pv.size());
    // check the values
    for (std::size_t k(0); k<number_of_tuples; k++) {
        ASSERT_EQ(static_cast<double>(k), pv[2*k]);
        ASSERT_EQ(static_cast<double>(k), pv[2*k+1]);
    }
}
Example #23
0
void vec2Di::and(const vec2Di& v)
{
        vec2Di& pv = *this;
        for (unsigned int i = 0; i < height(); i++)
                for (unsigned int j = 0; j < width(); j++)
                        pv(i, j) &= v(i, j);
}
Example #24
0
void SGListExtractOfRank::viewStructure(ostream& ostr) const
{
  EnumertatorProblemView pv(oid(),"Extract subgroups of a given rank from a list",
			    Text("Extract subgroups of a given rank from ") +
			    Name( theList ) ,
			    helpID("SGListExtractOfRank",
				   theList.getGroup()),
			    Text("rank sgs")
			    );
  
  pv.addParameter(EditInteger("minRank","Minimal rank ",0,0,0,30000));
  pv.addParameter(EditInteger("maxRank","Maximal rank ",0,100,0 ,30000));
  
  
  pv.addProblem( Subproblem("Sp1",ThisARCSlotID(),
			    Text("For the use of the problem"),40));
  
  // RadioButton rRB1("ToFile","Extract to a file");
  // RadioButton rRB2("ToList","Extract to another list");
    
  // RadioButtonGroup extractRBG("ExtractTo");
  
  //    extractRBG.add(rRB1);
  //  extractRBG.add(rRB2);
  
  //  pv.addParameter(extractRBG);
 
  submit(ostr, pv);

}
Example #25
0
void SMListExtractCommutatorsInFree::viewStructure(ostream& ostr) const
{
  EnumertatorProblemView pv(oid(),"Extract commutators from a list",
			    Text("Extract commutators from ") +
			    Name( theList ) ,
			    helpID("SMListExtractCommutatorsInFree",
				   theList.getGroup()),
			    Text("commut")
			    );
  
  //  RadioButton rRB1("ToFile","Extract to a file");
  //  RadioButton rRB2("ToList","Extract to another list");
  
  //  RadioButtonGroup extractRBG("ExtractTo");
  
  //  extractRBG.add(rRB1);
  //  extractRBG.add(rRB2);
  
  //  pv.addParameter(extractRBG);
  pv.addProblem( Subproblem("Sp1",ThisARCSlotID(),
			    Text("For the use of enumerator"),40));
  
  submit(ostr, pv);

}
Example #26
0
void MapListExtractInner::viewStructure(ostream& ostr) const
{
  EnumertatorProblemView pv(oid(),"Extract inner automorphisms from a list",
			    Text("Extract inner automorphisms from") +
			    Name( theList ) ,
			    helpID("MapListExtractInner",
				   theList.getGroup()),
			    Text("inner auto")
			    );
  
  //  pv.addParameter(EditInteger("minL","Minimal length ",0,1,1,30000));
  // pv.addParameter(EditInteger("maxL","Maximal length ",0,30000,1,30000));
  
  
  pv.addProblem( Subproblem("Sp1",ThisARCSlotID(),
			    Text("For the use of the problem"),40));
  
  //RadioButton rRB1("ToFile","Extract to a file");
  //RadioButton rRB2("ToList","Extract to another list");
    
  // RadioButtonGroup extractRBG("ExtractTo");
  
  //  extractRBG.add(rRB1);
  //  extractRBG.add(rRB2);

  //  pv.addParameter(extractRBG);
 
  submit(ostr, pv);

}
Example #27
0
void ImposterNode::GetOOBBoxScreenCoords(Entity * node, const Matrix4 & mvp, AABBox3 & screenBounds)
{
	const Rect & viewport = RenderManager::Instance()->GetViewport();
	MeshInstanceNode * mesh = dynamic_cast<MeshInstanceNode*>(node);
	if (mesh)
	{
		Vector3 corners[8];
		Vector3 screenVertices[8];

		mesh->GetBoundingBox().GetCorners(corners);
		const Matrix4 & worldTransform = mesh->GetWorldTransform();

		for (int32 k = 0; k < 8; ++k)
		{
			Vector4 pv(corners[k]);
			pv = pv * worldTransform;
			pv = pv * mvp;
			pv.x = (viewport.dx * 0.5f) * (1.f + pv.x/pv.w) + viewport.x;
			pv.y = (viewport.dy * 0.5f) * (1.f + pv.y/pv.w) + viewport.y;
			pv.z = (pv.z/pv.w + 1.f) * 0.5f;

			screenVertices[k] = Vector3(pv.x, pv.y, pv.z);
			screenBounds.AddPoint(screenVertices[k]);

		}
	}

	int32 count = node->GetChildrenCount();
	for (int32 i = 0; i < count; ++i)
	{
		GetOOBBoxScreenCoords(node->GetChild(i), mvp, screenBounds);
	}
}
Example #28
0
/*
*Function: Update
*Inputs:line name , time stamp, value
*Outputs:none
*Returns:none
*/
void  Graph::Update(const QString &tag,const QDateTime &dt, double v)
{
	//IT_IT("Graph::Update");
	
	if(!HasLine(tag))
	{
		static QColor colour_list[] = 
		{
			Qt::black,Qt::darkRed,Qt::darkGreen,Qt::darkBlue,Qt::red,Qt::green,
			Qt::yellow,Qt::cyan
		};
		AddLine(tag,colour_list[plotMap.size() % 8]);
	};
	//
	DATAMAP::iterator j = plotMap.find(tag);    
	DataMap::value_type pv(dt,v); 
	//
	(*j).second.insert(pv); 
	//
	if((int)(*j).second.size() > MaxPointsPerLine)
	{
		(*j).second.erase((*j).second.begin());
	};
	LastDateTime = dt;
	last_v = v;
};
inline pv ins(const pv &a,const pv &b)
{
    u=fabs(ln.cross(a-pnt[i]));
    v=fabs(ln.cross(b-pnt[i]))+u;
    tl=b-a;
    return pv(u*tl.x/v+a.x,u*tl.y/v+a.y);
}
Example #30
0
static void hook_dump_entry()
{
	PLDR_DATA_TABLE_ENTRY table;
	entry_hook           *ehook;

	ExAcquireFastMutex(&dump_sync);

	if (dump_imgbase != NULL && (table = find_image(dump_imgbase)))
	{
		if (table->BaseDllName.Buffer != NULL && table->EntryPoint != NULL &&
			img_cmp(&table->BaseDllName, L"dump_") || img_cmp(&table->BaseDllName, L"hiber_"))
		{
			if (ehook = mm_alloc(sizeof(entry_hook), 0))
			{
				memcpy(ehook->code, jmp_code, sizeof(jmp_code));
				ppv(ehook->code + DEST_OFF)[0] = dump_driver_entry;
				ppv(ehook->code + PARM_OFF)[0] = ehook;
				ehook->old_entry  = table->EntryPoint;
				table->EntryPoint = pv(ehook->code);					
			}
		}
		dump_imgbase = NULL;
	}
	ExReleaseFastMutex(&dump_sync);
}