• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ HOFFSET函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_symbol_datatype

/*-------------------------------------------------------------------------
 * Function:    create_symbol_datatype
 *
 * Purpose:     Create's the HDF5 datatype used for elements in the SWMR
 *              testing datasets.
 *
 * Parameters:  N/A
 *
 * Return:      Success:    An HDF5 type ID
 *              Failure:    -1
 *
 *-------------------------------------------------------------------------
 */
hid_t
create_symbol_datatype(void)
{
    hid_t sym_type_id;          /* Datatype ID for symbol */
    hid_t opaq_type_id;         /* Datatype ID for opaque part of record */

    /* Create opaque datatype to represent other information for this record */
    if((opaq_type_id = H5Tcreate(H5T_OPAQUE, (size_t)DTYPE_SIZE)) < 0)
        return -1;

    /* Create compound datatype for symbol */
    if((sym_type_id = H5Tcreate(H5T_COMPOUND, sizeof(symbol_t))) < 0)
        return -1;

    /* Insert fields in symbol datatype */
    if(H5Tinsert(sym_type_id, "rec_id", HOFFSET(symbol_t, rec_id), H5T_NATIVE_UINT64) < 0)
        return -1;
    if(H5Tinsert(sym_type_id, "info", HOFFSET(symbol_t, info), opaq_type_id) < 0)
        return -1;

    /* Close opaque datatype */
    if(H5Tclose(opaq_type_id) < 0)
        return -1;

    return sym_type_id;
} /* end create_symbol_datatype() */
开发者ID:FilipeMaia,项目名称:hdf5,代码行数:39,代码来源:swmr_common.c


示例2: create_ieee_complex256

/* Counterpart for complex256 */
hid_t create_ieee_complex256(const char *byteorder) {
  herr_t err = 0;
  hid_t float_id, complex_id;
  H5T_order_t h5order = H5Tget_order(H5T_NATIVE_LDOUBLE);

  complex_id = H5Tcreate(H5T_COMPOUND, sizeof(npy_complex256));
  float_id = H5Tcopy(H5T_NATIVE_LDOUBLE);
  if (float_id < 0)
  {
    H5Tclose(complex_id);
    return float_id;
  }

  if ((strcmp(byteorder, "little") == 0) && (h5order != H5T_ORDER_LE))
    err = H5Tset_order(float_id, H5T_ORDER_LE);
  else if ((strcmp(byteorder, "big") == 0) && (h5order != H5T_ORDER_BE))
    err = H5Tset_order(float_id, H5T_ORDER_BE);

  if (err < 0)
  {
    H5Tclose(complex_id);
    return err;
  }

  H5Tinsert(complex_id, "r", HOFFSET(npy_complex256, real), float_id);
  H5Tinsert(complex_id, "i", HOFFSET(npy_complex256, imag), float_id);
  H5Tclose(float_id);
  return complex_id;
}
开发者ID:bbudescu,项目名称:PyTables,代码行数:30,代码来源:utils.c


示例3: make_particle_type

/*-------------------------------------------------------------------------
 * function to create a datatype representing the particle struct
 *-------------------------------------------------------------------------
 */
static hid_t
make_particle_type(void)
{
    hid_t type_id;
    hid_t string_type;
    size_t type_size = sizeof(particle_t);

    /* Create the memory data type. */
    if ((type_id = H5Tcreate (H5T_COMPOUND, type_size )) < 0 )
        return -1;

    /* Insert fields. */
    string_type = H5Tcopy( H5T_C_S1 );
    H5Tset_size( string_type, (size_t)16 );

    if ( H5Tinsert(type_id, "Name", HOFFSET(particle_t, name) , string_type ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Lat", HOFFSET(particle_t, lati) , H5T_NATIVE_INT ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Long", HOFFSET(particle_t, longi) , H5T_NATIVE_INT ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Pressure", HOFFSET(particle_t, pressure) , H5T_NATIVE_FLOAT ) < 0 )
        return -1;
    if ( H5Tinsert(type_id, "Temperature", HOFFSET(particle_t, temperature) , H5T_NATIVE_DOUBLE ) < 0 )
        return -1;

    return type_id;
}
开发者ID:quinoacomputing,项目名称:HDF5,代码行数:32,代码来源:test_packet.c


示例4: hdf5

    /** Creates a HDF5 type identifier for the [kmer,abundance] structure. This type will be used
     * for dumping Count instances in a HDF5 file (like SortingCount algorithm does).
     * \param[in] isCompound : tells whether the structure is compound (SHOULD BE OBSOLETE IN THE FUTURE)
     * \return the HDF5 identifier for the type. */
    static hid_t hdf5 (bool& isCompound)
    {
        hid_t abundanceType = H5T_NATIVE_UINT16;

        if (sizeof(Number)==1) {
            abundanceType = H5T_NATIVE_UINT8;
        }
        else if (sizeof(Number)==2) {
            abundanceType = H5T_NATIVE_UINT16;
        }
        else if (sizeof(Number)==4) {
            abundanceType = H5T_NATIVE_UINT32;
        }
        else if (sizeof(Number)==8) {
            abundanceType = H5T_NATIVE_UINT64;
        }
        else {
            throw "Bad type size for Abundance HDF5 serialization";
        }

        hid_t result = H5Tcreate (H5T_COMPOUND, sizeof(Abundance));
        H5Tinsert (result, "value",      HOFFSET(Abundance, value),     Type::hdf5(isCompound));
        H5Tinsert (result, "abundance",  HOFFSET(Abundance, abundance), abundanceType);

        isCompound = true;

        return result;
    }
开发者ID:cdeltel,项目名称:gatb-core-mirrored,代码行数:32,代码来源:Abundance.hpp


示例5: gent_compound

/*-------------------------------------------------------------------------
 * Function:    gent_compound
 *
 * Purpose:     Generate a compound dataset in LOC_ID
 *
 *-------------------------------------------------------------------------
 */
static void gent_compound(hid_t loc_id)
{
    typedef struct s_t
    {
        char str1[20];
        char str2[20];
    } s_t;
    hid_t   sid, did, tid_c, tid_s;
    hsize_t dims[1] = {2};
    s_t     buf[2]  = {{"str1", "str2"}, {"str3", "str4"}};

    /* create dataspace */
    sid = H5Screate_simple(1, dims, NULL);

    /* create a compound type */
    tid_c = H5Tcreate(H5T_COMPOUND, sizeof(s_t));
    tid_s = H5Tcopy(H5T_C_S1);
    H5Tset_size(tid_s, 20);

    H5Tinsert(tid_c, "str1", HOFFSET(s_t,str1), tid_s);
    H5Tinsert(tid_c, "str2", HOFFSET(s_t,str2), tid_s);

    /* create dataset */
    did = H5Dcreate2(loc_id, DATASET_COMPOUND, tid_c, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    /* write */
    H5Dwrite(did, tid_c, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);

    /* close */
    H5Sclose(sid);
    H5Dclose(did);
    H5Tclose(tid_c);
    H5Tclose(tid_s);
}
开发者ID:Hulalazz,项目名称:rnnlib,代码行数:41,代码来源:h5copygentest.c


示例6: main

int main(int argc, char *argv[])
{
    hdf_sa_t arr[LEN];
    initArr(arr, LEN);

    // create data type corresponding to compound struct
    hid_t cid = H5Tcreate(H5T_COMPOUND, sizeof(hdf_sa_t));
    H5Tinsert(cid, "a", HOFFSET(hdf_sa_t, a), H5T_NATIVE_INT);
    H5Tinsert(cid, "b", HOFFSET(hdf_sa_t, b), H5T_NATIVE_FLOAT);
    H5Tinsert(cid, "c", HOFFSET(hdf_sa_t, c), H5T_NATIVE_DOUBLE);

    // write data to file
    hid_t fid = H5Fcreate("compound.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);

    // create data space
    hsize_t dim[1] = {LEN};
    hid_t space = H5Screate_simple(1, dim, NULL);
    hid_t dataset = H5Dcreate(fid, "compound", cid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);

    // write data 
    H5Dwrite(dataset, cid, H5S_ALL, H5S_ALL, H5P_DEFAULT, arr);

    H5Sclose(space);
    H5Dclose(dataset);
    H5Fclose(fid);

    return 0;
}
开发者ID:wxm71,项目名称:todo,代码行数:28,代码来源:compound.c


示例7: sizeof

void pyne::Material::_load_comp_protocol1(H5::H5File * db, std::string datapath, int row)
{
  H5::DataSet data_set = (*db).openDataSet(datapath);

  hsize_t data_offset[1] = {row};
  if (row < 0)
  {
    // Handle negative row indecies
    H5::DataSpace data_space = data_set.getSpace();
    hsize_t data_dims[1];
    int data_rank = data_space.getSimpleExtentDims(data_dims);
    data_offset[0] += data_dims[0];
  };

  // Grab the nucpath
  std::string nucpath;
  H5::Attribute nuc_attr = data_set.openAttribute("nucpath");
  hsize_t nuc_attr_len = nuc_attr.getStorageSize() / sizeof(char);
  H5::StrType nuc_attr_type(0, nuc_attr_len);
  nuc_attr.read(nuc_attr_type, nucpath);

  // Grab the nuclides
  std::vector<int> nuclides = h5wrap::h5_array_to_cpp_vector_1d<int>(db, nucpath, H5::PredType::NATIVE_INT);
  int nuc_size = nuclides.size();
  hsize_t nuc_dims[1] = {nuc_size};

  // Get the data hyperslab
  H5::DataSpace data_hyperslab = data_set.getSpace();
  hsize_t data_count[1] = {1};
  data_hyperslab.selectHyperslab(H5S_SELECT_SET, data_count, data_offset);

  // Get memory space for writing
  H5::DataSpace mem_space (1, data_count);

  // Get material type
  size_t material_struct_size = sizeof(pyne::material_struct) + sizeof(double)*(nuc_size);
  H5::CompType data_desc(material_struct_size);
  H5::ArrayType comp_values_array_type (H5::PredType::NATIVE_DOUBLE, 1, nuc_dims);

  // make the data table type
  data_desc.insertMember("name", HOFFSET(pyne::material_struct, name), H5::StrType(0, 20));
  data_desc.insertMember("mass", HOFFSET(pyne::material_struct, mass), H5::PredType::NATIVE_DOUBLE);
  data_desc.insertMember("atoms_per_mol", HOFFSET(pyne::material_struct, atoms_per_mol), H5::PredType::NATIVE_DOUBLE);
  data_desc.insertMember("comp", HOFFSET(pyne::material_struct, comp), comp_values_array_type);

  // make the data array, have to over-allocate
  material_struct * mat_data = (material_struct *) malloc(material_struct_size);

  // Finally, get data and put in on this instance
  data_set.read(mat_data, data_desc, mem_space, data_hyperslab);

  name = std::string((*mat_data).name);
  mass = (*mat_data).mass;
  atoms_per_mol = (*mat_data).atoms_per_mol;
  for (int i = 0; i < nuc_size; i++)
    comp[nuclides[i]] = (double) (*mat_data).comp[i];

  free(mat_data);
};
开发者ID:chrisdembia,项目名称:pyne,代码行数:59,代码来源:material.cpp


示例8: hdf5

 inline static hid_t hdf5 (bool& compound)
 {
     hid_t result = H5Tcreate (H5T_COMPOUND, sizeof(Entry));
     H5Tinsert (result, "index",      HOFFSET(Entry, index),     H5T_NATIVE_UINT16);
     H5Tinsert (result, "abundance",  HOFFSET(Entry, abundance), H5T_NATIVE_UINT64);
     compound = true;
     return result;
 }
开发者ID:zy26,项目名称:gatb-core,代码行数:8,代码来源:IHistogram.hpp


示例9: require_group

void NSDFWriter::createEventMap()
{
    herr_t status;    
    hid_t eventMapContainer = require_group(filehandle_, MAPEVENTSRC);
    // Open the container for the event maps
    // Create the Datasets themselves (one for each field - each row
    // for one object).
    for (map< string, vector < string > >::iterator ii = classFieldToEventSrc_.begin();
         ii != classFieldToEventSrc_.end();
         ++ii){
        vector < string > pathTokens;
        tokenize(ii->first, "/", pathTokens);
        string className = pathTokens[0];
        string fieldName = pathTokens[1];
        hid_t classGroup = require_group(eventMapContainer, className);
        hid_t strtype = H5Tcopy(H5T_C_S1);
        status = H5Tset_size(strtype, H5T_VARIABLE);
        // create file space
        hid_t ftype = H5Tcreate(H5T_COMPOUND, sizeof(hvl_t) +sizeof(hobj_ref_t));
        status = H5Tinsert(ftype, "source", 0, strtype);
        status = H5Tinsert(ftype, "data", sizeof(hvl_t), H5T_STD_REF_OBJ);
        hsize_t dims[1] = {ii->second.size()};
        hid_t space = H5Screate_simple(1, dims, NULL);
        // The dataset for mapping is named after the field
        hid_t ds = H5Dcreate2(classGroup, fieldName.c_str(), ftype, space,
                              H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
        status = H5Sclose(space);
        map_type * buf = (map_type*)calloc(ii->second.size(), sizeof(map_type));
        // Populate the buffer entries with source uid and data
        // reference
        for (unsigned int jj = 0; jj < ii->second.size(); ++jj){
            buf->source = ii->second[jj].c_str();
            char * dsname = (char*)calloc(256, sizeof(char));
            ssize_t size = H5Iget_name(classFieldToEvent_[ii->first][jj], dsname, 255);
            if (size > 255){
                free(dsname);
                dsname = (char*)calloc(size, sizeof(char));
                size = H5Iget_name(classFieldToEvent_[ii->first][jj], dsname, 255);
            }
            status = H5Rcreate(&(buf->data), filehandle_, dsname, H5R_OBJECT, -1);
            free(dsname);
            assert(status >= 0);            
        }
        // create memory space
        hid_t memtype = H5Tcreate(H5T_COMPOUND, sizeof(map_type));
        status = H5Tinsert(memtype, "source",
                           HOFFSET(map_type, source), strtype);
        status = H5Tinsert(memtype, "data",
                           HOFFSET(map_type, data), H5T_STD_REF_OBJ);
        status = H5Dwrite(ds, memtype,  H5S_ALL, H5S_ALL, H5P_DEFAULT, buf);
        free(buf);
        status = H5Tclose(strtype);
        status = H5Tclose(ftype);
        status = H5Tclose(memtype);
        status = H5Dclose(ds);
    }
}
开发者ID:asiaszmek,项目名称:moose-core,代码行数:57,代码来源:NSDFWriter.cpp


示例10: arma_H5Tcreate

inline
hid_t
get_hdf5_type< std::complex<double> >()
  {
  hid_t type = arma_H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t<double>));

  arma_H5Tinsert(type, "real", HOFFSET(hdf5_complex_t<double>, real), arma_H5T_NATIVE_DOUBLE);
  arma_H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t<double>, imag), arma_H5T_NATIVE_DOUBLE);

  return type;
  }
开发者ID:RcppCore,项目名称:RcppArmadillo,代码行数:11,代码来源:hdf5_misc.hpp


示例11: H5Tcreate

inline
hid_t
get_hdf5_type< std::complex<float> >()
  {
  hid_t type = H5Tcreate(H5T_COMPOUND, sizeof(hdf5_complex_t<float>));
  
  H5Tinsert(type, "real", HOFFSET(hdf5_complex_t<float>, real), H5T_NATIVE_FLOAT);
  H5Tinsert(type, "imag", HOFFSET(hdf5_complex_t<float>, imag), H5T_NATIVE_FLOAT);
  
  return type;
  }
开发者ID:ELEN4002-Lab-Project-2012,项目名称:ELEN4002-Lab-Project,代码行数:11,代码来源:hdf5_misc.hpp


示例12: get_species_comp_type

 static H5::CompType get_species_comp_type()
 {
     H5::CompType h5_species_comp_type(sizeof(h5_species_struct));
     h5_species_comp_type.insertMember(
         std::string("id"), HOFFSET(h5_species_struct, id),
         H5::PredType::STD_I32LE);
     h5_species_comp_type.insertMember(
         std::string("serial"), HOFFSET(h5_species_struct, serial),
         H5::StrType(H5::PredType::C_S1, 32));
     return h5_species_comp_type;
 }
开发者ID:greatlse,项目名称:ecell4,代码行数:11,代码来源:ParticleSpaceHDF5Writer.hpp


示例13: get_particle_comp_type

 static H5::CompType get_particle_comp_type()
 {
     H5::CompType h5_particle_comp_type(sizeof(h5_particle_struct));
     h5_particle_comp_type.insertMember(
         std::string("lot"), HOFFSET(h5_particle_struct, lot),
         H5::PredType::NATIVE_INT);
     h5_particle_comp_type.insertMember(
         std::string("serial"), HOFFSET(h5_particle_struct, serial),
         H5::PredType::NATIVE_INT);
     h5_particle_comp_type.insertMember(
         std::string("sid"), HOFFSET(h5_particle_struct, sid),
         H5::PredType::STD_I32LE);
     h5_particle_comp_type.insertMember(
         std::string("posx"), HOFFSET(h5_particle_struct, posx),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("posy"), HOFFSET(h5_particle_struct, posy),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("posz"), HOFFSET(h5_particle_struct, posz),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("radius"), HOFFSET(h5_particle_struct, radius),
         H5::PredType::NATIVE_DOUBLE);
     h5_particle_comp_type.insertMember(
         std::string("D"), HOFFSET(h5_particle_struct, D),
         H5::PredType::NATIVE_DOUBLE);
     return h5_particle_comp_type;
 }
开发者ID:greatlse,项目名称:ecell4,代码行数:29,代码来源:ParticleSpaceHDF5Writer.hpp


示例14: write

void write(hid_t& file, std::vector<Region>& regions)
{
  const size_t record_size = sizeof(Region);

  size_t record_offset[] = { HOFFSET(Region, bam_file_key),
                             HOFFSET(Region, chromosome),
                             HOFFSET(Region, region_name),
                             HOFFSET(Region, start),
                             HOFFSET(Region, stop),
                             HOFFSET(Region, strand),
                             HOFFSET(Region, count),
                             HOFFSET(Region, normalized_count) };

  size_t field_sizes[] = { sizeof(Region::bam_file_key),
                           sizeof(Region::chromosome),
                           sizeof(Region::region_name),
                           sizeof(Region::start),
                           sizeof(Region::stop),
                           sizeof(Region::strand),
                           sizeof(Region::count),
                           sizeof(Region::normalized_count) };

  herr_t status = H5TBappend_records(file, "region_counts", regions.size(), record_size, record_offset,
                                     field_sizes, regions.data());
  if (status != 0)
  {
    std::stringstream ss;
    ss << "Error appending record, status = " << status;
    throw std::runtime_error(ss.str());
  }
}
开发者ID:BoulderLabs,项目名称:pipeline,代码行数:31,代码来源:bamliquidator_regions.m.cpp


示例15: linkDatatype

hid_t linkDatatype()
{
	hid_t tLink;
	hid_t tPosition;
	hid_t tNumber;	
	
	tLink = H5Tcreate(H5T_COMPOUND, sizeof(link_t));
	tPosition = H5Tcopy(H5T_NATIVE_INT32);
	tNumber = H5Tcopy(H5T_NATIVE_INT32);
	H5Tinsert(tLink, "position", HOFFSET(link_t, position), tPosition);
	H5Tinsert(tLink, "number", HOFFSET(link_t, number), tNumber);
	H5Tclose(tPosition);
	H5Tclose(tNumber);
	return tLink;
}
开发者ID:hbredin,项目名称:pinocchIO,代码行数:15,代码来源:structure_utils.c


示例16: create_ieee_complex128

/* Counterpart for complex128 */
hid_t create_ieee_complex128(const char *byteorder) {
  hid_t float_id, complex_id;

  complex_id = H5Tcreate(H5T_COMPOUND, sizeof(npy_complex128));
  if (byteorder == NULL)
    float_id = H5Tcopy(H5T_NATIVE_DOUBLE);
  else if (strcmp(byteorder, "little") == 0)
    float_id = H5Tcopy(H5T_IEEE_F64LE);
  else
    float_id = H5Tcopy(H5T_IEEE_F64BE);
  H5Tinsert(complex_id, "r", HOFFSET(npy_complex128, real), float_id);
  H5Tinsert(complex_id, "i", HOFFSET(npy_complex128, imag), float_id);
  H5Tclose(float_id);
  return complex_id;
}
开发者ID:andreas-h,项目名称:PyTables,代码行数:16,代码来源:utils.c


示例17: readDoubleComplexMatrix

int readDoubleComplexMatrix(int _iDatasetId, double *_pdblReal, double *_pdblImg)
{
    hid_t compoundId;
    herr_t status;
    int iDims = 0;
    int* piDims = NULL;
    int iComplex = 0;
    int iSize = 1;
    doublecomplex* pData = NULL;
    int i = 0;

    /*define compound dataset*/
    compoundId = H5Tcreate(H5T_COMPOUND, sizeof(doublecomplex));
    H5Tinsert(compoundId, "real", HOFFSET(doublecomplex, r), H5T_NATIVE_DOUBLE);
    H5Tinsert(compoundId, "imag", HOFFSET(doublecomplex, i), H5T_NATIVE_DOUBLE);

    //get dimension from dataset
    getDatasetInfo(_iDatasetId, &iComplex, &iDims, NULL);
    piDims = (int*)MALLOC(sizeof(int) * iDims);
    iSize = getDatasetInfo(_iDatasetId, &iComplex, &iDims, piDims);
    if (iSize < 0)
    {
        FREE(piDims);
        return -1;
    }

    FREE(piDims);
    //alloc temp array
    pData = (doublecomplex*)MALLOC(sizeof(doublecomplex) * iSize);
    //Read the data.
    status = H5Dread(_iDatasetId, compoundId, H5S_ALL, H5S_ALL, H5P_DEFAULT, pData);
    if (status < 0)
    {
        FREE(pData);
        return -1;
    }


    vGetPointerFromDoubleComplex(pData, iSize, _pdblReal, _pdblImg);
    FREE(pData);
    status = H5Dclose(_iDatasetId);
    if (status < 0)
    {
        return -1;
    }

    return 0;
}
开发者ID:ScilabOrg,项目名称:scilab,代码行数:48,代码来源:h5_readDataFromFile.c


示例18: main

int main(){
  hid_t fprop;
  hid_t fid;
  hid_t vol_id = H5VL_memvol_init();
  char name[1024];

  // create some datatypes

  hid_t tid = H5Tcreate (H5T_COMPOUND, sizeof(complex_type));
  H5Tinsert(tid, "re", HOFFSET(complex_type,re), H5T_NATIVE_DOUBLE);
  H5Tinsert(tid, "im", HOFFSET(complex_type,im), H5T_NATIVE_DOUBLE);
  hid_t s10 = H5Tcopy(H5T_C_S1);
  H5Tset_size(s10, 10);
  H5Tinsert(tid, "name", HOFFSET(complex_type,name), s10);
  H5Tinsert(tid, "val", HOFFSET(complex_type,val), H5T_NATIVE_INT);

  // packed version of the datatype
  hid_t disk_tid = H5Tcopy (tid);
  H5Tpack(disk_tid);

  fprop = H5Pcreate(H5P_FILE_ACCESS);
  H5Pset_vol(fprop, vol_id, &fprop);

  fid = H5Fcreate("test", H5F_ACC_TRUNC, H5P_DEFAULT, fprop);
  H5VLget_plugin_name(fid, name, 1024);
  printf ("%s using VOL %s\n", __FILE__ , name);

  assert(H5Tcommit(fid, "t_complex", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0);
  assert(H5Tcommit(fid, "t_complex_p", disk_tid,  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) >= 0);

  hid_t tid_stored1 = H5Topen(fid, "t_complex", H5P_DEFAULT);
  hid_t tid_stored2 = H5Topen(fid, "t_complex_p", H5P_DEFAULT);
  // hid_t tid_stored3 = H5Topen(fid, "NotExisting", H5P_DEFAULT);
  // assert(tid_stored3 < 0);

  assert(H5Tequal(tid_stored1, tid));
  assert(H5Tequal(tid_stored2, disk_tid));

  H5Fclose(fid);

  H5Tclose(tid);
  H5Tclose(disk_tid);

  H5VL_memvol_finalize();

  return 0;
}
开发者ID:ESiWACE,项目名称:ESD-Middleware,代码行数:47,代码来源:direct-datatype.c


示例19: atom_dec_desc

void pyne::_load_atomic_decay()
{
  // Loads the important parts of atomic_decay table into memory

  //Check to see if the file is in HDF5 format.
  if (!pyne::file_exists(pyne::NUC_DATA_PATH))
    throw pyne::FileNotFound(pyne::NUC_DATA_PATH);

  bool isH5 = H5::H5File::isHdf5(pyne::NUC_DATA_PATH);
  if (!isH5)
    throw h5wrap::FileNotHDF5(pyne::NUC_DATA_PATH);


  // Get the HDF5 compound type (table) description
  H5::CompType atom_dec_desc(sizeof(atomic_decay_struct));
  atom_dec_desc.insertMember("from_nuc_name", HOFFSET(atomic_decay_struct, from_nuc_name), H5::StrType(0, 6));
  atom_dec_desc.insertMember("from_nuc_zz",   HOFFSET(atomic_decay_struct, from_nuc_zz),   H5::PredType::NATIVE_INT);
  atom_dec_desc.insertMember("level", HOFFSET(atomic_decay_struct, level), H5::PredType::NATIVE_DOUBLE);
  atom_dec_desc.insertMember("to_nuc_name", HOFFSET(atomic_decay_struct, to_nuc_name), H5::StrType(0, 6));
  atom_dec_desc.insertMember("to_nuc_zz",   HOFFSET(atomic_decay_struct, to_nuc_zz),   H5::PredType::NATIVE_INT);
  atom_dec_desc.insertMember("half_life", HOFFSET(atomic_decay_struct, half_life), H5::PredType::NATIVE_DOUBLE);
  atom_dec_desc.insertMember("decay_const", HOFFSET(atomic_decay_struct, decay_const), H5::PredType::NATIVE_DOUBLE);
  atom_dec_desc.insertMember("branch_ratio", HOFFSET(atomic_decay_struct, branch_ratio), H5::PredType::NATIVE_DOUBLE);

  // Open the HDF5 file
  H5::H5File nuc_data_h5 (pyne::NUC_DATA_PATH.c_str(), H5F_ACC_RDONLY);

  // Open the data set
  H5::DataSet atom_dec_set = nuc_data_h5.openDataSet("/atomic_decay");
  H5::DataSpace atom_dec_space = atom_dec_set.getSpace();
  int atom_dec_length = atom_dec_space.getSimpleExtentNpoints();

  // Read in the data
  atomic_decay_struct * atom_dec_array = new atomic_decay_struct[atom_dec_length];
  atom_dec_set.read(atom_dec_array, atom_dec_desc);

  // close the nuc_data library, before doing anythng stupid
  nuc_data_h5.close();

  // Ok now that we have the array of stucts, put it in the maps
  // giving precednece to ground state values or those seen first.
  int from_nuc;
  double level;
  for(int n = 0; n < atom_dec_length; n++)
  {
    from_nuc = atom_dec_array[n].from_nuc_zz;
    level = atom_dec_array[n].level;

    if (0 == half_life_map.count(from_nuc) || 0.0 == level)
      half_life_map[from_nuc] = atom_dec_array[n].half_life;

    if (0 == decay_const_map.count(from_nuc) || 0.0 == level)
      decay_const_map[from_nuc] = atom_dec_array[n].decay_const;
  };
};
开发者ID:chrisdembia,项目名称:pyne,代码行数:55,代码来源:data.cpp


示例20: create_hl_table

/* Create a normal HL table just like the HL examples do */
static int create_hl_table(hid_t fid)
{
    /* Calculate the offsets of the particle struct members in memory */
    size_t part_offset[NFIELDS] = { HOFFSET( particle_t, name ),
                                    HOFFSET( particle_t, lati ),
                                    HOFFSET( particle_t, longi ),
                                    HOFFSET( particle_t, pressure ),
                                    HOFFSET( particle_t, temperature )
                                  };

    /* Define field information */
    const char *field_names[NFIELDS]  =
    { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
    hid_t      field_type[NFIELDS];
    hid_t      string_type;
    hsize_t    chunk_size = 10;
    int        *fill_data = NULL;
    int        compress  = 0;
    herr_t     status;

    /* Initialize the field field_type */
    string_type = H5Tcopy( H5T_C_S1 );
    H5Tset_size( string_type, (size_t)16 );
    field_type[0] = string_type;
    field_type[1] = H5T_NATIVE_INT;
    field_type[2] = H5T_NATIVE_INT;
    field_type[3] = H5T_NATIVE_FLOAT;
    field_type[4] = H5T_NATIVE_DOUBLE;


    /*------------------------------------------------------------------------
    * H5TBmake_table
    *-------------------------------------------------------------------------
    */

    status=H5TBmake_table( "Table Title", fid, H5TB_TABLE_NAME, (hsize_t)NFIELDS,
                           (hsize_t)NRECORDS, sizeof(particle_t),
                           field_names, part_offset, field_type,
                           chunk_size, fill_data, compress, testPart  );

    if(status<0)
        return -1;
    else
        return 0;
}
开发者ID:quinoacomputing,项目名称:HDF5,代码行数:46,代码来源:test_packet.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HOKUYO_EXCEPT函数代码示例发布时间:2022-05-30
下一篇:
C++ HMAC_Update函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap