当前位置: 首页>>代码示例>>C++>>正文


C++ H5Tget_size函数代码示例

本文整理汇总了C++中H5Tget_size函数的典型用法代码示例。如果您正苦于以下问题:C++ H5Tget_size函数的具体用法?C++ H5Tget_size怎么用?C++ H5Tget_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了H5Tget_size函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AH5_H5Tcreate_cpx_filetype

hid_t AH5_H5Tcreate_cpx_filetype(void)
{
    hid_t cpx_filetype;

    cpx_filetype = H5Tcreate(H5T_COMPOUND, H5Tget_size(AH5_NATIVE_FLOAT) * 2);
    H5Tinsert(cpx_filetype, "r", 0, AH5_NATIVE_FLOAT);
    H5Tinsert(cpx_filetype, "i", H5Tget_size(AH5_NATIVE_FLOAT), AH5_NATIVE_FLOAT);

    return cpx_filetype;
}
开发者ID:ThinkManhattan,项目名称:amelet-hdf,代码行数:10,代码来源:ah5_general.c

示例2: main

int
main(int argc, char **argv)
{
    char file_name[256], dset_name[256];
    hid_t file_id, dataset_id, space_id, plist_id, type_id;
    hsize_t dims[1], dims_chunk[1];
    hsize_t maxdims[1] = { H5S_UNLIMITED };
    size_t disk_type_size, computed_type_size, packed_type_size;

    if (argc < 3) {
        printf("Pass the name of the file and dataset to check as arguments\n");
        return(0);
    }

    strcpy(file_name, argv[1]);
    strcpy(dset_name, argv[2]);
    
    dims[0] = 20;  // Create 20 records
    dims_chunk[0] = 10;

    // Create a new file
    file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
    // Create a simple data space with unlimited size
    space_id = H5Screate_simple(1, dims, maxdims);
    // Modify dataset creation properties, i.e. enable chunking
    plist_id = H5Pcreate (H5P_DATASET_CREATE);
    H5Pset_chunk(plist_id, 1, dims_chunk);
    // Get the nested type
    type_id = createNestedType();
    // Create the dataset
    dataset_id = H5Dcreate(file_id, dset_name, type_id, space_id, plist_id);
    // Free resources
    H5Sclose(space_id);
    H5Pclose(plist_id);
    H5Dclose(dataset_id);
    H5Fclose(file_id);

    // Compute type sizes for native and packed
    disk_type_size = H5Tget_size(type_id);
    computed_type_size = getNestedSizeType(type_id);
    H5Tpack(type_id);  // pack type
    packed_type_size = H5Tget_size(type_id);
    printf("Disk type size: %d\n", disk_type_size);
    printf("Packed type size: %d (should be %d)\n",
           packed_type_size, computed_type_size);

    H5Tclose(type_id);

    return(1);
}
开发者ID:87,项目名称:PyTables,代码行数:50,代码来源:create-nested-type.c

示例3: get_attribute_float

static herr_t get_attribute_float(hid_t input, const char *name, float *val)
{
    hid_t attr_id;
    hid_t type_id;
    H5T_class_t type_class;
    size_t type_size;

    herr_t status;

    char *strval;

    attr_id = H5Aopen_name(input, name);
    type_id = H5Aget_type(attr_id);
    type_class = H5Tget_class(type_id);
    type_size = H5Tget_size(type_id);

    H5Tclose(type_id);
    H5Aclose(attr_id);

    switch(type_class)
    {
        case H5T_STRING:
            status = get_attribute_str(input, name, &strval);
            if (status < 0) return -1;
                *val = atof(strval);
            free(strval);
            return 0;
        case H5T_FLOAT:
            status = get_attribute(input, name, H5T_NATIVE_FLOAT, val);
            if (status < 0) return -1;
            return 0;
    }
    return -1;
}
开发者ID:QuLogic,项目名称:citcoms,代码行数:34,代码来源:Citcoms_Hdf2Vtk.c

示例4: read_vector

void read_vector(
    hid_t dataset_id,
    hid_t datatype_id,
    hid_t dataspace_id,
    std::vector<std::string>& out) {

  hsize_t size;
  hsize_t dims[1];

  H5Sget_simple_extent_dims(dataspace_id, dims, NULL);

  size = H5Tget_size(datatype_id);

  char *pool = new char[ size * dims[0] ];
  char *ptr = pool;
  char *buf = new char[size];

  H5Dread(dataset_id, datatype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, pool);
  out.reserve(dims[0]);

  for (size_t i = 0; i < dims[0]; ++i, ptr += size) {
    memcpy(buf, ptr, size);
    out.push_back( buf );
  }

  delete [] pool;
  delete [] buf;
}
开发者ID:Al3n70rn,项目名称:clustering_on_transcript_compatibility_counts,代码行数:28,代码来源:h5utils.cpp

示例5: AH5_read_str_attr

// Read string attribute <attr_name> given by address <path>
char AH5_read_str_attr(hid_t loc_id, const char *path, char *attr_name, char **rdata)
{
    hid_t attr_id, filetype, memtype;
    size_t sdim;
    char success = AH5_FALSE;

    if (AH5_path_valid(loc_id, path) || strcmp(path, ".") == 0)
        if (H5Aexists_by_name(loc_id, path, attr_name, H5P_DEFAULT) > 0)
        {
            attr_id = H5Aopen_by_name(loc_id, path, attr_name, H5P_DEFAULT, H5P_DEFAULT);
            filetype = H5Aget_type(attr_id);
            sdim = H5Tget_size(filetype);
            sdim++;  // make a space for null terminator
            *rdata = (char *) malloc(sdim * sizeof(char));
            memtype = H5Tcopy(H5T_C_S1);
            H5Tset_size(memtype, sdim);
            if (H5Aread(attr_id, memtype, *rdata) >= 0)
                success = AH5_TRUE;
            else
                free(*rdata);
            H5Tclose(memtype);
            H5Tclose(filetype);
            H5Aclose(attr_id);
        }
    if (!success)
        *rdata = NULL;
    return success;
}
开发者ID:ThinkManhattan,项目名称:amelet-hdf,代码行数:29,代码来源:ah5_attribute.c

示例6: print_dset_dtype_meta

/*-------------------------------------------------------------------------
 * Function: print_dset_dtype_meta
 *
 * Purpose: Prints datasets' datatype information
 *
 * Return: Success: 0
 *
 * Failure: Never fails
 *
 * Programmer: Vailin Choi; October 2009
 *
 *-------------------------------------------------------------------------
 */
static herr_t
print_dset_dtype_meta(const iter_t *iter)
{
    unsigned long total;        /* Total count for various statistics */
    size_t   dtype_size;        /* Size of encoded datatype */
    unsigned u;                 /* Local index variable */

    if(iter->dset_ntypes) {
        printf("Dataset datatype information:\n");
        printf("\t# of unique datatypes used by datasets: %lu\n", iter->dset_ntypes);
        total = 0;
        for(u = 0; u < iter->dset_ntypes; u++) {
            H5Tencode(iter->dset_type_info[u].tid, NULL, &dtype_size);
            printf("\tDataset datatype #%u:\n", u);
            printf("\t\tCount (total/named) = (%lu/%lu)\n",
                    iter->dset_type_info[u].count, iter->dset_type_info[u].named);
            printf("\t\tSize (desc./elmt) = (%lu/%lu)\n", (unsigned long)dtype_size,
                    (unsigned long)H5Tget_size(iter->dset_type_info[u].tid));
            H5Tclose(iter->dset_type_info[u].tid);
            total += iter->dset_type_info[u].count;
        } /* end for */
        printf("\tTotal dataset datatype count: %lu\n", total);
    } /* end if */

    return 0;
} /* print_dset_dtype_meta() */
开发者ID:ArielleBassanelli,项目名称:gempak,代码行数:39,代码来源:h5stat.c

示例7: h5_value_doubles

void h5_value_doubles(hid_t file_id, char *group, char *name, double **values,
	int *numValues)
{
  int kk;
  hid_t group_id = H5Gopen(file_id, group, H5P_DEFAULT);
  hid_t data_id = H5Dopen(group_id, name, H5P_DEFAULT);
  hid_t data_space = H5Dget_space(data_id);
  int rank = H5Sget_simple_extent_ndims(data_space);
  hsize_t dims[H5S_MAX_RANK], maxdim[H5S_MAX_RANK];
  H5Sget_simple_extent_dims(data_space, dims, maxdim);
  hid_t data_type = H5Dget_type(data_id);
  H5T_class_t data_class = H5Tget_native_type(data_type, H5T_DIR_DEFAULT);
  size_t data_size = H5Tget_size(data_class);  
  hsize_t elements = 1;
  for (kk=0; kk<rank; kk++)
    elements *= dims[kk];
  void *buf = (void *) MALLOC((size_t)(elements*data_size));
  H5Dread(data_id, data_class, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
  *values = buf;
  *numValues = elements;
  H5Tclose(data_type);
  H5Tclose(data_class);
  H5Sclose(data_space);
  H5Dclose(data_id);
  H5Gclose(group_id); 
}
开发者ID:khogenso,项目名称:ASF_MapReady,代码行数:26,代码来源:measures_hdf2csv.c

示例8: luaC_h5_read_string

int luaC_h5_read_string(lua_State *L)
{
  const char *dsetnm = luaL_checkstring(L, 1);
  if (PresentFile < 0) {
    luaL_error(L, "no open file");
  }
  hid_t dset = H5Dopen(PresentFile, dsetnm, H5P_DEFAULT);
  if (dset < 0) {
    luaL_error(L, "no data set named %s", dsetnm);
  }
  hid_t fspc = H5Dget_space(dset);
  hid_t strn = H5Dget_type(dset);
  hsize_t msize = H5Tget_size(strn);

  char *string = (char*) malloc((msize+1)*sizeof(char));

  H5Dread(dset, strn, fspc, fspc, H5P_DEFAULT, string);
  string[msize] = '\0'; // Make sure to null-terminate the string
  lua_pushstring(L, string);

  H5Tclose(strn);
  H5Sclose(fspc);
  H5Dclose(dset);
  free(string);

  return 1;
}
开发者ID:jzrake,项目名称:luview,代码行数:27,代码来源:h5lua.c

示例9: miget_data_type_size

/** Return the byte size of the voxel datatytpe
 */
int miget_data_type_size ( mihandle_t volume, misize_t *voxel_size )
{
  hid_t grp_id;
  hid_t dset_id;
  hid_t type_id;
  hid_t file_id = volume->hdf_id;

  grp_id = midescend_path ( file_id, MI_FULLIMAGE_PATH );

  if ( grp_id < 0 ) {
    return ( MI_ERROR );
  }

  dset_id = H5Dopen1 ( grp_id, "image" );

  if ( dset_id < 0 ) {
    return ( MI_ERROR );
  }

  type_id = H5Dget_type ( dset_id );

  if ( type_id < 0 ) {
    return ( MI_ERROR );
  }

  *voxel_size = H5Tget_size ( type_id );

  H5Tclose ( type_id );
  H5Dclose ( dset_id );
  H5Gclose ( grp_id );

  return ( MI_NOERROR );
}
开发者ID:SiyaSher,项目名称:libminc,代码行数:35,代码来源:datatype.c

示例10: getNestedSizeType

size_t
getNestedSizeType(hid_t type_id) {
    hid_t member_type_id;
    H5T_class_t class_id;
    hsize_t i, nfields;
    size_t itemsize, offset;

    nfields = H5Tget_nmembers(type_id);
    offset = 0;
    // Iterate thru the members
    for (i=0; i < nfields; i++) {
        // Get the member type
        member_type_id = H5Tget_member_type(type_id, i);
        // Get the HDF5 class
        class_id = H5Tget_class(member_type_id);
        if (class_id == H5T_COMPOUND) {
            // Get the member size for compound type
            itemsize = getNestedSizeType(member_type_id);
        }
        else {
            // Get the atomic member size
            itemsize = H5Tget_size(member_type_id);
        }
        // Update the offset
        offset = offset + itemsize;
    }
    return(offset);
}      
开发者ID:87,项目名称:PyTables,代码行数:28,代码来源:create-nested-type.c

示例11: H5Dataset_read_attr_value

/* read attribute value */
char* H5Dataset_read_attr_value(hid_t aid)
{
    hid_t asid=-1, atid=-1;
    int i, rank;
    hsize_t *dims;
    size_t size=1;
    char *attr_buf=NULL;
  
    asid = H5Aget_space(aid);
    atid = H5Aget_type(aid);
    rank = H5Sget_simple_extent_ndims(asid);

    if (rank > 0) {
        dims = (hsize_t *)malloc(rank * sizeof(hsize_t));
        H5Sget_simple_extent_dims(asid, dims, NULL);
        for (i=0; i<rank; i++) {
            size *= (size_t)dims[i];
            free(dims);
        }
        size *= H5Tget_size(atid);
        attr_buf = (char *)malloc(size);

        if (H5Aread( aid, atid, attr_buf) < 0) {
            free(attr_buf);
            attr_buf = NULL;
        }

    }
    
    if( atid > 0) H5Tclose(atid);
    if (asid > 0) H5Sclose(asid);
 
    return attr_buf;
}
开发者ID:DICE-UNC,项目名称:iRODS-FUSE-Mod,代码行数:35,代码来源:h5Dataset.c

示例12: get_cols

/* fetch num_cols and the col for a particular trackname */
void get_cols(chromosome_t *chromosome, char *trackname, hsize_t *num_cols,
              hsize_t *col) {
  hid_t attr, root, dataspace, datatype;
  hsize_t data_size, cell_size, num_cells;
  char *attr_data;

  /* Tracknames are stored in the attributes of the root group of each file */
  root = H5Gopen(chromosome->h5group, "/", H5P_DEFAULT);
  assert(root >= 0);

  attr = H5Aopen_name(root, "tracknames");
  assert(attr >= 0);

  dataspace = H5Aget_space(attr);
  assert(dataspace >= 0);

  assert(H5Sget_simple_extent_dims(dataspace, num_cols, NULL) == 1);
  assert(H5Sclose(dataspace) >= 0);

  if (trackname && col) {
    datatype = H5Aget_type(attr);
    assert(datatype >= 0);
    assert(H5Tget_class(datatype) == H5T_STRING);

    cell_size = H5Tget_size(datatype);
    assert(cell_size > 0);

    data_size = H5Aget_storage_size(attr);
    assert(data_size > 0);

    num_cells = data_size / cell_size;

    /* allocate room for tracknames */
    attr_data = xmalloc(data_size);
    assert(attr_data);

    assert(H5Aread(attr, datatype, attr_data) >= 0);

    *col = 0;
    for (*col = 0; *col <= num_cells; (*col)++) {
      if (*col == num_cells) {
        fprintf(stderr, "can't find trackname: %s\n", trackname);
        free(attr_data);
        exit(EXIT_FAILURE);
      } else {
        if (!strncmp(attr_data + (*col * cell_size), trackname, cell_size)) {
          break;
        }
      }
    }

    /* clean up read tracknames */
    free(attr_data);
  }

  assert(H5Aclose(attr) >= 0);
}
开发者ID:weallen,项目名称:Seqwill,代码行数:58,代码来源:genomedata_load_data.c

示例13: AH5_auto_test_file

char *test_read_complex_dataset()
{

    int i,rank = 1;
    hsize_t dims[1];
    hid_t dataspace_id, dset_id, dtr_id, dti_id, file_id;
    size_t type_size;
    hid_t type_id;
    herr_t status, status_2;
    float *real_part, *imag_part;
    const char* path = "dataset_name";
    AH5_complex_t cplx[2];
    AH5_complex_t * rdata;

    file_id = AH5_auto_test_file();

    cplx[0].re=10.;
    cplx[0].im=20.;
    cplx[1].re=10.5;
    cplx[1].im=20.5;
    //first write complex array set with hdf5 lib
	real_part = (float *)malloc(2 * sizeof(float));
    imag_part = (float *)malloc(2 * sizeof(float));
    for( i=0;i<2;i++)
    {
        real_part[i] = cplx[i].re;
        imag_part[i] = cplx[i].im;
    }
    type_id = create_type_id(H5T_NATIVE_FLOAT);
    dims[0] = 2;
    dataspace_id = H5Screate_simple(rank, dims, NULL);
    dset_id = H5Dcreate(file_id,path,type_id,dataspace_id,
                H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
    type_size = H5Tget_size(H5T_NATIVE_FLOAT);
    dtr_id = H5Tcreate(H5T_COMPOUND,type_size);
    status = H5Tinsert(dtr_id,"r",0, H5T_NATIVE_FLOAT);
    dti_id = H5Tcreate(H5T_COMPOUND,type_size);
    status = H5Tinsert(dti_id,"i",0, H5T_NATIVE_FLOAT);
    status = H5Dwrite(dset_id,dtr_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,real_part);
    status = H5Dwrite(dset_id,dti_id,H5S_ALL,H5S_ALL,H5P_DEFAULT,imag_part);
    status = H5Tclose(dtr_id);
    status = H5Tclose(dti_id);
    free(real_part);
    free(imag_part);
    mu_assert("Read complex dataset.",
        		AH5_read_cpx_dataset(file_id,"dataset_name", 2, &rdata));

    for (i = 0; i < 2; i++)
    {
      	printf("Real parts : %f %f\n", cplx[i].re, rdata[i].re);
       	printf("Imaginary parts : %f %f\n", cplx[i].im, rdata[i].im);
       	mu_assert_equal("Check the real values.", cplx[i].re, rdata[i].re);
       	mu_assert_equal("Check the imaginary value.", cplx[i].im, rdata[i].im);
    }

    return MU_FINISHED_WITHOUT_ERRORS;
}
开发者ID:ThinkManhattan,项目名称:amelet-hdf,代码行数:57,代码来源:dataset.c

示例14: print_sizes

void print_sizes( const char *obj1,
                  const char *obj2,
                  hid_t f_tid1,
                  hid_t f_tid2,
                  hid_t m_tid1,
                  hid_t m_tid2 )
{
    size_t  f_size1, f_size2;       /* size of type in file */
    size_t  m_size1, m_size2;       /* size of type in memory */

    f_size1 = H5Tget_size( f_tid1 );
    f_size2 = H5Tget_size( f_tid2 );
    m_size1 = H5Tget_size( m_tid1 );
    m_size2 = H5Tget_size( m_tid2 );

    parallel_print("\n");
    parallel_print("------------------\n");
    parallel_print("sizeof(char)   %u\n", sizeof(char) );
    parallel_print("sizeof(short)  %u\n", sizeof(short) );
    parallel_print("sizeof(int)    %u\n", sizeof(int) );
    parallel_print("sizeof(long)   %u\n", sizeof(long) );
    parallel_print("<%s> ------------------\n", obj1);
    parallel_print("type on file   ");
    print_type(f_tid1);
    parallel_print("\n");
    parallel_print("size on file   %u\n", f_size1 );

    parallel_print("type on memory ");
    print_type(m_tid1);
    parallel_print("\n");
    parallel_print("size on memory %u\n", m_size1 );

    parallel_print("<%s> ------------------\n", obj2);
    parallel_print("type on file   ");
    print_type(f_tid2);
    parallel_print("\n");
    parallel_print("size on file   %u\n", f_size2 );

    parallel_print("type on memory ");
    print_type(m_tid2);
    parallel_print("\n");
    parallel_print("size on memory %u\n", m_size2 );
    parallel_print("\n");
}
开发者ID:lsubigdata,项目名称:hdf5ssh,代码行数:44,代码来源:h5diff_dset.c

示例15: H5Tget_sign

DataType ImageBase::datatypeH5(hid_t h5datatype)
{
    H5T_sign_t h5sign = H5Tget_sign(h5datatype);

    //    if (h5sign == H5T_SGN_ERROR)
    //        REPORT_ERROR(ERR_IO, "datatypeHDF5: Integer sign error in dataset.");
    bool sign = (h5sign > H5T_SGN_NONE);
    size_t size = H5Tget_size(h5datatype);

    DataType dt;
    switch(H5Tget_class(h5datatype))
    {
    case H5T_FLOAT:
        {
            switch(size)
            {
            case 4:
                dt = DT_Float;
                break;
            case 8:
                dt = DT_Double;
                break;
            default:
                REPORT_ERROR(ERR_IO_SIZE, "datatypeHDF5: bad datatype size");
            }
        }
        break;
    case H5T_INTEGER:
        {
            switch(size)
            {
            case 1:
                dt = (sign)? DT_SChar : DT_UChar;
                break;
            case 2:
                dt = (sign)? DT_Short : DT_UShort;
                break;
            case 4:
                dt = (sign)? DT_Int : DT_UInt;
                break;
            case 8:
                dt = (sign)? DT_Long : DT_ULong;
                break;
            default:
                REPORT_ERROR(ERR_IO_SIZE, "datatypeHDF5: bad datatype size");
            }
        }
        break;
    case H5T_NO_CLASS:
    default:
        dt = DT_Unknown;
        break;
    }
    return dt;
}
开发者ID:I2PC,项目名称:scipion,代码行数:55,代码来源:rwHDF5.cpp


注:本文中的H5Tget_size函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。