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


C++ BasicVec类代码示例

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


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

示例1: find_with_index

template<class VB> BasicVec<unsigned> find_with_index(const VB &to_check) {
    BasicVec<unsigned> res; res.reserve( to_check.size() );
    for(unsigned i=0;i<to_check.size();++i)
        if ( to_check[i] )
            res.push_back( i );
    return res;
}
开发者ID:structure-computation,项目名称:scult,代码行数:7,代码来源:write_xdmf.cpp

示例2: make_lnk_compilation_tree

Ptr<CompilationTree> CompilationEnvironment::make_compilation_tree( const String &app, const String &cpp, bool lib, bool dyn, bool make_libs ) {
    BasicVec<Ptr<CompilationTree> > obj;
    parse_cpp( obj, cpp, dyn );

    // sort by directory
    if ( make_libs ) {
        String base_dir = directory_of( cpp );
        std::map<String,Lib> map_lib;
        for( int i = 0; i < obj.size(); ++i ) {
            String dir = directory_of( obj[ i ]->children[ 0 ]->dst );
            if ( dir == base_dir )
                continue;
            map_lib[ dir ].obj << obj[ i ];
            obj.remove( i-- );
        }

        // make dylibs
        int cpt = 0;
        for( std::map<String,Lib>::iterator iter = map_lib.begin(); iter != map_lib.end(); ++iter ) {
            String name; name << app << "_" << cpt++;
            obj << make_lnk_compilation_tree( lib_for( name, dyn ), iter->second.obj, true, dyn );
        }
    }

    //
    return make_lnk_compilation_tree( app, obj, lib, dyn );
}
开发者ID:hleclerc,项目名称:Metil,代码行数:27,代码来源:CompilationEnvironment.cpp

示例3: write_groups_datasets_2

void write_groups_datasets_2(std::ofstream &f,Sc2String input_hdf5, Sc2String name_group_elements){
    //lecture des noms des listes d'elements
//     int nb_elems_tot=0;
//     int nb_nodes_elem_glob=4;
    Hdf hdf(input_hdf5);
    BasicVec<Sc2String> lists;
    lists=hdf.list_dir(name_group_elements);
    for (unsigned i=0; i< lists.size(); i++) {
        Sc2String name_list; name_list << name_group_elements << "/"<<lists[i];
        Sc2String name_list_c0=name_list+"/mesh_c0";
        int nb_elems;
        hdf.read_size(name_list_c0,nb_elems); //lecture du nombre d'elements dans la liste
        //lecture du type d'elements
        int nb_nodes_elem;
        Metil::String base;
        hdf.read_tag(name_list,"base",base,1);
        if (base=="Bar") nb_nodes_elem=2;                   // Bar
        else if (base=="Bar_3") nb_nodes_elem=2;            // Bar_3, on ne prend que les 2 premiers noeuds
        else if (base=="Triangle") nb_nodes_elem=3;         // Triangle
        else if (base=="Triangle_6") nb_nodes_elem=3;       // Triangle_6, on ne prend que les 3 premiers noeuds
        else if (base=="Quadrilateral") nb_nodes_elem=4;    // quad
        else if (base=="Tetrahedron") nb_nodes_elem=4;      // Tetra
        else if (base=="Tetrahedron_10") nb_nodes_elem=10;  // Tetra_10,   on ne prend que les 4 premiers noeuds
        else if (base=="Hexahedron") nb_nodes_elem=8;       // quad
        else { std::cerr << "Type d'element non implementé - voir le tag \"base\" dans le fichier hdf5" ; assert(0);}
        
        for (unsigned j=0;j<nb_nodes_elem ; j++) {
            Sc2String data_item;
            data_item << name_list << "/mesh_c" <<j ;
            f <<"           <DataItem Name=\"" << data_item << "\" Format=\"HDF\" NumberType=\"Int\" Dimensions=\" "<< nb_elems << " 1\">" <<  input_hdf5 <<":"<< data_item <<" </DataItem>" << endl;
        }
    }
}
开发者ID:structure-computation,项目名称:scult,代码行数:33,代码来源:write_xdmf.cpp

示例4:

		BasicVec<Data> operator+(const BasicVec<DataT2>& rhs) const
		{
			return BasicVec<Data>(
				x() + rhs.x(),
				y() + rhs.y(),
				z() + rhs.z()
			);
		}
开发者ID:UIKit0,项目名称:aqsis,代码行数:8,代码来源:vec_array_view.cpp

示例5: z

		BasicVec<Data> operator%(const BasicVec<DataT2>& rhs) const
		{
			return BasicVec<Data>(
				y()*rhs.z() - z()*rhs.y(),
				z()*rhs.y() - y()*rhs.z(),
				x()*rhs.y() - y()*rhs.z()
			);
		}
开发者ID:UIKit0,项目名称:aqsis,代码行数:8,代码来源:vec_array_view.cpp

示例6: deepest_child

Ptr<CompilationTree> CompilationEnvironment::make_lnk_compilation_tree( const String &exe, const BasicVec<Ptr<CompilationTree> > &obj, bool lib, bool dyn ) {
    Ptr<CompilationTree> &res = deepest_child()->cor_files[ exe ];
    if ( not res ) {
        res = NEW( CompilationTree, exe );
        for( int i = 0; i < obj.size(); ++i )
            res->add_child( obj[ i ] );
        BasicVec<String> obj_str;
        for( int i = 0; i < obj.size(); ++i )
            obj_str << obj[ i ]->dst;
        res->cmd = lnk_cmd( exe, obj_str, lib, dyn );
    }
    return res;
}
开发者ID:hleclerc,项目名称:Metil,代码行数:13,代码来源:CompilationEnvironment.cpp

示例7: write_groups_attributs_datasets

void write_groups_attributs_datasets(std::ofstream &f,Sc2String input_hdf5, Sc2String name_elements, Sc2String name_fields, BasicVec<Sc2String>  attributs, int time) {
    Hdf hdf(input_hdf5);
    BasicVec<Sc2String> lists;
    lists=hdf.list_dir(name_elements);

#if DIM==2
    BasicVec<Sc2String> tensor_comp("xx","yy","xy");
    BasicVec<Sc2String> vector_comp("x","y");    
#else
    BasicVec<Sc2String> tensor_comp("xx","yy","zz","xy","xz","yz");
    BasicVec<Sc2String> vector_comp("x","y","z");
#endif
    BasicVec<Sc2String> list_fields_tensor_time("sigma","epsilon","sigma_skin", "epsilon_skin");
    BasicVec<Sc2String> list_fields_vector_time("F", "W", "Fchap", "Wchap");
    BasicVec<Sc2String> list_fields_scalar_time("sigma_von_mises","sigma_von_mises_skin");
    BasicVec<Sc2String> list_fields_global("num_proc","material","num_group", "number", "nature");
    
    for (unsigned i=0; i< lists.size(); i++) {
        Sc2String name_list;
        name_list << name_elements <<"/"<< lists[i];
        Sc2String name_list_c0=name_list+"/mesh_c0";
        int nb_elems;
        hdf.read_size(name_list_c0,nb_elems);

        //Ecriture des attributs en fonction de leur nom
        
        for (unsigned attr=0;attr<attributs.size();attr++) {
            if (find(attributs[attr], list_fields_tensor_time) ) {
                for(unsigned d=0;d<tensor_comp.size();d++){
                    Sc2String name_field; name_field << name_fields << "/pt_"<<time<<"/"<<attributs[attr]<<"/"<<lists[i]<<"/"<<tensor_comp[d];
                    f <<"           <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field <<" </DataItem>" << endl;                
                }        
            }
            else if (find(attributs[attr], list_fields_vector_time) ) {
                for(unsigned d=0;d<DIM;d++){
                    Sc2String name_field; name_field << name_fields << "/pt_"<<time<<"/"<<attributs[attr]<<"/"<<lists[i]<<"/"<<vector_comp[d];
                    f <<"           <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field <<" </DataItem>" << endl;                
                }        
            }
            else if (find(attributs[attr], list_fields_scalar_time) ) {
                Sc2String name_field; name_field << name_fields << "/pt_"<<time<<"/"<<attributs[attr]<<"/"<<lists[i];
                f <<"           <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field << " </DataItem>" << endl;
            }
            else if (find(attributs[attr], list_fields_global)) {
                Sc2String name_field; name_field << name_elements << "/"<<lists[i]<<"/"<<attributs[attr];
                f <<"           <DataItem Name=\"" << name_field <<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_elems << " \">" << input_hdf5 <<":"<< name_field << " </DataItem>" << endl;
            }
        }
    }
}
开发者ID:structure-computation,项目名称:scult,代码行数:50,代码来源:write_xdmf.cpp

示例8: find

bool find(Sc2String name, BasicVec<Sc2String> list){
    bool res=0; 
    for(unsigned i=0;i<list.size();i++){
        if(name==list[i]){res=1; break;}
    }
    return res;
}
开发者ID:structure-computation,项目名称:scult,代码行数:7,代码来源:write_xdmf.cpp

示例9: find_src

String CompilationEnvironment::find_src( const String &filename, const String &current_dir, const BasicVec<String> &add_paths, bool allow_cur_dir ) const {
    // absolute path ?
    if ( filename[ 0 ] == '/' or filename[ 0 ] == '\\' )
        return ( file_exists( filename ) ? filename : String() );

    // try with current_dir
    String trial = current_dir + filename;    
    if ( allow_cur_dir and file_exists( trial ) )
        return trial;

    // try with add_paths
    for( int i = 0; i < add_paths.size(); ++i ) {
        trial = add_paths[ i ] + filename;
        if ( file_exists( trial ) )
            return trial;
    }

    // try with inc_paths
    for( int i = 0; i < inc_paths.size(); ++i ) {
        trial = inc_paths[ i ] + filename;
        if ( file_exists( trial ) )
            return trial;
    }

    // try with inc_paths of child
    if ( child )
        return child->find_src( filename, current_dir );

    // not found :(
    return String();
}
开发者ID:hleclerc,项目名称:Metil,代码行数:31,代码来源:CompilationEnvironment.cpp

示例10:

void StructCompactor::ItemStr::make_defi( String &os, const String &pr, BasicVec<String> &already_defined ) {
    if ( already_defined.contains( pr + type ) )
        return;
    already_defined << pr + type;

    static const char *lsl[] = { "_load", "_save" };
    for( int save = 0; save < 2; ++save ) {
        const char *ls = lsl[ save ];
        for( int gpu = 0; gpu < 2; ++gpu ) {
            if ( gpu ) {
                os << "__global__\n";
                os << "void " << pr.replace( ':', '_' ) << type << "__update_ptr_gpu" << ls << "( " << pr << type << " *obj, ST off ) {\n";
            } else
                os << "void " << pr << type << "::update_ptr_cpu" << ls << "( ST off ) {\n";
            //
            for( int i = 0; i < items.size(); ++i )
                items[ i ]->make_uptr( os, ( gpu ? "obj->" : "" ) + items[ i ]->name, 0, "    ", save );

            os << "}\n";
            os << "\n";
            if ( gpu ) {
                os << "void " << pr << type << "::update_ptr_gpu" << ls << "( ST off ) {\n";
                os << "    " << pr.replace( ':', '_' ) << type << "__update_ptr_gpu" << ls << "<<<1,1>>>( this, off );\n";
                os << "}\n";
                os << "\n";
            }
        }
    }
    for( int i = 0; i < items.size(); ++i )
        items[ i ]->make_defi( os, pr + type + "::", already_defined );
}
开发者ID:hleclerc,项目名称:Metil,代码行数:31,代码来源:StructCompactor.cpp

示例11: write_nodes_attributs_datasets

void write_nodes_attributs_datasets(std::ofstream &f,Sc2String input_hdf5,int nb_nodes,Sc2String name_fields, BasicVec<Sc2String>  attributs, int time, int i_proc) {
    //ecriture des attributs aux noeuds
    BasicVec<Sc2String> dimensions("x","y","z");
    for (unsigned attr=0;attr<attributs.size();attr++) {
        if (attributs[attr]=="displacements" or attributs[attr]=="displacements_skin") 
            for(unsigned d=0;d<DIM;d++){
                Sc2String name_field; name_field << name_fields <<"/pt_"<<time<<"/"<<attributs[attr]<<"/"<<dimensions[d];
                f <<"           <DataItem Name=\""<<name_field<<"_proc_"<<i_proc<<"\" Format=\"HDF\" NumberType=\"Float\" Precision=\"8\" Dimensions=\" "<< nb_nodes << " 1 \">" << input_hdf5 <<":"<< name_field<< " </DataItem>" << endl;
            }
    }
}
开发者ID:structure-computation,项目名称:scult,代码行数:11,代码来源:write_xdmf.cpp

示例12: aaadd

 void aaadd( BasicVec<String> var_templ, BasicVec<BasicVec<String,2> > rep ) {
     if ( var_templ.size() ) {
         BasicVec<String> t = tokenize( var_templ.back(), ' ' );
         var_templ.pop_back();
         
         for( int i = 1; i < t.size(); ++i ) {
             rep.push_back( t[ 0 ], t[ i ] );
             aaadd( var_templ, rep );
             rep.pop_back();
         }
     } else
         res << rep;
 }
开发者ID:hleclerc,项目名称:Metil,代码行数:13,代码来源:CompilationEnvironment.cpp

示例13: lnk_cmd

String CompilationEnvironment::lnk_cmd( const String &exe, const BasicVec<String> &obj, bool lib, bool dyn ) const {
    String cmd = get_LD();
    // basic flags
    if ( lib )
        cmd << ( dyn ? " -shared" : " -static" );
    // input / output
    cmd << " -o '" << exe << "'";
    for( int i = 0; i < obj.size(); ++i )
        cmd << " '" << obj[ i ] << "'";
    // -L... -l...
    extra_lnk_cmd( cmd, lib, dyn );
    // dylibs
    for (int i = 0; i < dylibs.size(); ++i)
        cmd << " " << dylibs[ i ];
    return cmd;
}
开发者ID:hleclerc,项目名称:Metil,代码行数:16,代码来源:CompilationEnvironment.cpp

示例14: tokenize

void CompilationEnvironment::load_env_var() {
    if ( String str = get_env( "METIL_INC_PATHS" ) ) {
        BasicVec<String> lst = tokenize( str, ';' );
        for( int i = 0; i < lst.size(); ++i )
            add_inc_path( lst[ i ] );
    }

    if ( String str = get_env( "METIL_LIB_PATHS" ) ) {
        BasicVec<String> lst = tokenize( str, ';' );
        for( int i = 0; i < lst.size(); ++i )
            add_lib_path( lst[ i ] );
    }

    if ( String str = get_env( "METIL_LIB_NAMES" ) ) {
        BasicVec<String> lst = tokenize( str, ';' );
        for( int i = 0; i < lst.size(); ++i )
            add_lib_name( lst[ i ] );
    }

    if ( String str = get_env( "METIL_PARSED" ) ) {
        BasicVec<String> lst = tokenize( str, ';' );
        for( int i = 0; i < lst.size(); ++i )
            parsed << lst[ i ];
    }

    if ( String str = get_env( "METIL_COMP_DIR"  ) ) _comp_dir = str;
    if ( String str = get_env( "METIL_CXX"       ) ) CXX       = str;
    if ( String str = get_env( "METIL_LD"        ) ) LD        = str;
    if ( String str = get_env( "METIL_NVCC"      ) ) NVCC      = str;
    if ( String str = get_env( "METIL_CPPFLAGS"  ) ) CPPFLAGS  = str;
    if ( String str = get_env( "METIL_LDFLAGS"   ) ) LDFLAGS   = str;
    if ( String str = get_env( "METIL_DEV_EMU"   ) ) device_emulation = Val( str );
    if ( String str = get_env( "METIL_REG_CNT"   ) ) maxrregcount = Val( str );
    if ( String str = get_env( "METIL_DBG_LEVEL" ) ) dbg_level = Val( str );
    if ( String str = get_env( "METIL_OPT_LEVEL" ) ) opt_level = Val( str );
    if ( String str = get_env( "METIL_CXX_NAME"  ) ) cxx_name  = str;
}
开发者ID:hleclerc,项目名称:Metil,代码行数:37,代码来源:CompilationEnvironment.cpp

示例15: last_modification_time_or_zero_of_file_named

bool CompilationCppParser::init_using_dep( CompilationEnvironment &ce, const String &cpp_file, const String &dep_file ) {
    SI64 date_cpp = last_modification_time_or_zero_of_file_named( cpp_file );
    SI64 date_dep = last_modification_time_or_zero_of_file_named( dep_file );
    if ( date_cpp > date_dep )
        return false;

    File fd( dep_file, "r" );
    const char *c = fd.c_str();

    // orig flags are conform ?
    BasicVec<String> loc_inc_paths;
    BasicVec<String> loc_def_procs;
    load_dep_vec( c, loc_inc_paths );
    load_dep_vec( c, loc_def_procs );
    if ( ce_inc_paths.size() != loc_inc_paths.size() or ce_def_procs.size() != loc_def_procs.size() )
        return false;
    if ( any( ce_inc_paths != loc_inc_paths ) or any( ce_def_procs != loc_def_procs ) )
        return false;


    // include file are older than dep file ?
    load_dep_vec( c, inc_files );
    for( ST i = 0; i < inc_files.size(); ++i ) {
        if ( last_modification_time_or_zero_of_file_named( inc_files[ i ] ) > date_dep ) {
            inc_files.resize( 0 );
            return false;
        }
    }

    // -> OK
    load_dep_vec( c, moc_files );
    load_dep_vec( c, src_files );

    load_dep_vec( c, lib_paths );
    load_dep_vec( c, lib_names );
    load_dep_vec( c, fra_names );
    load_dep_vec( c, inc_paths );
    load_dep_vec( c, cpp_flags );
    load_dep_vec( c, lnk_flags );
    load_dep_vec( c, gpu_flags );
    load_dep_vec( c, var_templ );
    load_dep_vec( c, cxx_name  );

    BasicVec<String> defs;
    load_dep_vec( c, defs );
    for( int i = 0; i < defs.size(); ++i )
        defines[ defs[ i ] ];

    // .h.py ?
    for( int i = 0; i < inc_files.size(); ++i ) {
        String inc_file = inc_files[ i ];
        if ( inc_file.ends_with( ".h" ) ) {
            String h_py = inc_file + ".py";
            if ( file_exists( h_py ) ) {
                if ( last_modification_time_or_zero_of_file_named( h_py ) >
                     last_modification_time_or_zero_of_file_named( inc_file ) )
                    make_h_py( h_py, inc_file );
            }
        }
    }

    return true;
}
开发者ID:hleclerc,项目名称:Metil,代码行数:63,代码来源:CompilationCppParser.cpp


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