本文整理汇总了C++中H5File::CreateDataSet方法的典型用法代码示例。如果您正苦于以下问题:C++ H5File::CreateDataSet方法的具体用法?C++ H5File::CreateDataSet怎么用?C++ H5File::CreateDataSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类H5File
的用法示例。
在下文中一共展示了H5File::CreateDataSet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ArraySize
TEST(H5Handle_Test, WriteReadTest) {
float data[12];
for (size_t i = 0; i < ArraySize(data); i++) {
data[i] = i;
}
{
H5File file;
file.SetFile("tmp.h5");
file.Open(true);
hsize_t dims[] = {3,4};
hsize_t chunking[] = {3,4};
H5DataSet *ds = file.CreateDataSet("/tmp/here/testdata", 2, dims, chunking, 2, H5T_NATIVE_FLOAT);
size_t starts[] = {0,0};
size_t ends[] = {3,4};
//ds->WriteRangeData(starts, ends, ArraySize(data), data);
ds->WriteRangeData(starts, ends, data);
ds->Close();
}
{
H5File file;
file.SetFile("tmp.h5");
file.Open();
H5DataSet *ds = file.OpenDataSet("/tmp/here/testdata");
float query[12];
size_t starts[] = {0,0};
size_t ends[] = {3,4};
ds->ReadRangeData(starts, ends, ArraySize(query), query);
for (size_t i = 0; i < ArraySize(data); i++) {
if (data[i] != query[i]) {
EXPECT_EQ(query[i], data[i]);
}
}
{
float update[4];
size_t starts[] = {1,2};
size_t ends[] = {3,4};
size_t count = 0;
for (size_t i = 11; i >= 8; i--) {
update[count++] = i;
}
//ds->WriteRangeData(starts, ends, ArraySize(update), update);
ds->WriteRangeData(starts, ends, update);
float query[12];
size_t rstarts[] = {0,0};
size_t rends[] = {3,4};
float gold[12] = {0,1,2,3,4,5,11,10,8,9,9,8};
ds->ReadRangeData(rstarts, rends, ArraySize(query), query);
for (size_t i = 0; i < 1; i++) {
EXPECT_EQ(gold[i], query[i]);
}
}
// ds->Close();
ds = file.OpenDataSet("shouldbenull");
EXPECT_EQ(NULL,ds);
}
}
示例2: RotateMyCube
void RotatingCube::RotateMyCube ( H5File &h5_local_ref, int total_blocks, const char *cube_name, const char *cube_description )
{
char s[128];
string str;
for ( int i=0; i<total_blocks; i++ )
{
sprintf ( s,"%s/block_%04d",cube_name, i );
H5DataSet *ptr = h5_local_ref.CreateDataSet ( s, source, 3 );
sprintf ( s,"%s",cube_description );
h5_local_ref.CreateAttribute ( ptr->getDataSetId(),"description",s );
h5_local_ref.makeParamNames ( "ndx_",source.GetNumZ(),str );
h5_local_ref.CreateAttribute ( ptr->getDataSetId(),"paramNames",str.c_str() );
h5_vec.push_back ( ptr );
}
}
示例3: InitBasicCube
// set up a basic data cube + matched h5 set
//@TODO: use templates to avoid "INT" duplication
void MatchedCubeInt::InitBasicCube ( H5File &h5_local_ref, int col, int row, int maxflows, const char *set_name, const char *set_description, const char *param_root )
{
//printf ( "%s\n",set_name );
string str;
source.Init ( col, row, maxflows );
source.SetRange ( 0,col, 0, row, 0, maxflows );
source.AllocateBuffer();
h5_set = h5_local_ref.CreateDataSet ( set_name, source, 3 );
h5_local_ref.CreateAttribute ( h5_set->getDataSetId(),"description",set_description );
// either we're just using the axis for nothing special
if ( strlen ( param_root ) <1 )
{
h5_local_ref.makeParamNames ( "ndx_",maxflows, str );
}
else
{
// or we have a specific set of variables for this axis
str = param_root;
}
h5_local_ref.CreateAttribute ( h5_set->getDataSetId(),"paramNames",str.c_str() );
}
示例4:
TEST(H5Handle_Test, MatrixTest) {
Mat<float> mymat = ones<Mat<float> >(5,3);
Mat<float>::iterator i;
int count = 0;
for (i = mymat.begin(); i != mymat.end(); i++) {
*i = count++;
}
// mymat.raw_print(cout);
{
H5File file;
file.SetFile("tmp.h5");
file.Open(true);
H5DataSet *ds = file.CreateDataSet("/tmp/fun/mat", mymat, 0);
//H5DataSet *ds = file.CreateDataSet("mat", mymat, 0);
ds->WriteMatrix(mymat);
ds->Close();
}
{
H5File file;
file.SetFile("tmp.h5");
file.Open();
H5DataSet *ds = file.OpenDataSet("/tmp/fun/mat");
// H5DataSet *ds = file.OpenDataSet("mat");
Mat<float> m;
ds->ReadMatrix(m);
// m.raw_print(cout);
Mat<float>::iterator gold, test;
for (gold = mymat.begin(), test = m.begin(); gold != mymat.end(); gold++, test++) {
float g = *gold;
float t = *test;
EXPECT_EQ(t, g);
}
ds->Close();
}
}