Esempio n. 1
0
	C_ListType & operator = (const C_ListType &other) {
		if (this != &other) {
			C_ListType tmp_list(other);
			Swap(tmp_list);
		}
		return(*this);
	}
    model::IPixelCorrectionModel& PixelCorrectionQueue::add_model(const model::IPixelCorrectionModel& model)
    {
        model::IPixelCorrectionModel* new_mod = model.clone();

        std::list<model::IPixelCorrectionModel*> tmp_list(correction_model_.begin(), correction_model_.end());
        tmp_list.push_front(new_mod);

        correction_model_.assign(tmp_list.begin(), tmp_list.end());
        ++n_models_;

        return *new_mod;
    }
Esempio n. 3
0
	GetStatsForAllAdapter(ApiForType *api_for_type, const char *stat_type_name,
		const char *api_for_type_name, const char *get_func_name,
		ThisFuncPtr get_func_ptr)
		:api_for_type_(api_for_type)
		,stat_type_name_(stat_type_name)
		,api_for_type_name_(api_for_type_name)
		,get_func_name_(get_func_name)
		,get_func_ptr_(get_func_ptr)
		,stat_list_()
	{
		std::vector<typename StatsType::MyLbmApiStatsType> tmp_list(1024);

		for ( ; ; ) {
			int tmp_size        = static_cast<int>(tmp_list.size());
			int lbm_return_code = (*get_func_ptr_)(api_for_type, &tmp_size,
				sizeof(tmp_list[0]), &(tmp_list[0]));
			if (!lbm_return_code) {
				if (static_cast<std::size_t>(tmp_size) < tmp_list.size())
					tmp_list.resize(static_cast<std::size_t>(tmp_size));
				break;
			}
			else if ((lbm_return_code == -1) && (::lbm_errnum() == LBM_EINVAL)) {
				/*
					Some kinda logic error if LBM returns an indication that there's
					not enough room for the list, but there actually is...
				*/
				if (static_cast<std::size_t>(tmp_size) <= tmp_list.size()) {
					std::ostringstream o_str;
					o_str << "An attempt to retrieve statistics information for "
						"all " << stat_type_name_ << " within a " <<
						api_for_type_name_ << " failed because the LBM function '" <<
						get_func_name_ << "()' indicated that a total of " <<
						tmp_list.size() << " elements was insufficient to store the "
						"data, but that " << tmp_size << "elements would suffice.";
					MLB::Utility::ThrowLogicError(o_str.str());
				}
				else
					tmp_list.resize(tmp_list.size() + 1024);	//	For an MT env.
			}
			else {
				WRAP29_LBM_THROW_STRING_NAME(get_func_name_);
			}
		}

		if (!tmp_list.empty()) {
			std::size_t                stat_count = tmp_list.size();
			const ThisLbmApiStatsType *stat_ptr   = &(tmp_list[0]);
			stat_list_.reserve(stat_count);
			for ( ; stat_count; --stat_count, ++stat_ptr)
				stat_list_.push_back(StatsType(*stat_ptr));
		}
	}
int main(int argc, char* argv[])
{
    v_circular_buffer_2.push_back(1);
    v_circular_buffer_2.push_back(4);

    MyClass tmp(x);
    v_intrusive_set_2.insert(tmp);

    MyClass_list tmp_list(x);
    v_intrusive_list_2.push_front(tmp_list);

    int r = done();  // break here
    r += argc + (char)argv[0][0];
    return r % 2;
}
Esempio n. 5
0
//----------------------------------------------------------------------
void Wannier_method::calculate_overlap(Array1 <int> & orb_list,
                                       Array3 <dcomplex> & eikr, Array2 <doublevar> & phi2phi2) {


    Array1 <Array1 <int> > tmp_list(1);
    tmp_list(0)=orb_list;
    mymomat->buildLists(tmp_list);
    int list=0;

    Array2 <doublevar>  gvec(3,3);
    if(!sys->getPrimRecipLattice(gvec) ) error("Need getPrimRecipLattice");

    int norb=orb_list.GetDim(0);
    eikr.Resize(3,norb,norb);
    phi2phi2.Resize(norb,norb);
    eikr=0.0;
    phi2phi2=0.0;

    Array1 <doublevar> prop(3);
    Array1 <doublevar> n_lat(3);
    n_lat=0.0;
    for(int d=0; d < 3; d++) {
        for(int d1=0; d1 < 3; d1++)
            n_lat(d)+=LatticeVec(d,d1)*LatticeVec(d,d1);
        n_lat(d)=sqrt(n_lat(d));
        prop(d)=resolution/double(n_lat(d));
        //cout << "prop " << prop(d) <<  " res " << resolution << " norm " << n_lat(d) << endl;
    }

    cout << "calculating...." << endl;
    mymovals.Resize(norb,1);
    Array1 <doublevar> r(3),x(3);
    Array1 <doublevar> norm_orb(norb);
    norm_orb=0.0;
    int totpts=0;
    for(r(0)=origin(0); r(0) < 1.0; r(0)+=prop(0)) {
        cout << "percent done: " << r(0)*100 << endl;
        for(r(1)=origin(1); r(1) < 1.0; r(1)+=prop(1)) {
            for(r(2)=origin(2); r(2) < 1.0; r(2)+=prop(2)) {

                totpts++;
                for(int d=0; d< 3; d++) {
                    x(d)=0.0;
                    for(int d1=0; d1 < 3; d1++) {
                        x(d)+=r(d1)*LatticeVec(d1,d);
                    }
                }

                mywalker->setElectronPos(0,x);
                mymomat->updateVal(mywalker,0,list,mymovals);
                for(int i=0; i < norb; i++) norm_orb(i)+=mymovals(i,0)*mymovals(i,0);
                for(int d=0; d< 3; d++) {
                    doublevar gdotr=0;
                    for(int d1=0; d1 < 3; d1++) {
                        gdotr+=gvec(d,d1)*x(d1);
                    }
                    dcomplex exp_tmp=exp(dcomplex(0,-1)*2.*pi*gdotr);
                    for(int i=0; i< norb; i++) {
                        for(int j=0; j< norb; j++) {
                            eikr(d,i,j)+=exp_tmp*mymovals(i,0)*mymovals(j,0);
                        }
                    }
                }
                for(int i=0; i< norb; i++) {
                    for(int j=0; j< norb; j++) {
                        phi2phi2(i,j)+=mymovals(i,0)*mymovals(i,0)*mymovals(j,0)*mymovals(j,0);
                    }
                }
            }
        }
    }

    for(int i=0; i< norb; i++) norm_orb(i)=sqrt(norm_orb(i));

    for(int d=0; d< 3; d++) {
        for(int i=0; i < norb; i++) {
            for(int j=0; j< norb; j++) {
                eikr(d,i,j)/=norm_orb(i)*norm_orb(j);
                //cout << d << " " << i << " " <<  j << " " << eikr(d,i,j) << endl;
            }
        }
    }
    cout << "square overlap " << endl;
    for(int i=0; i < norb; i++) {
        for(int j=0; j< norb; j++) {
            phi2phi2(i,j)/=(norm_orb(i)*norm_orb(i)*norm_orb(j)*norm_orb(j));
            cout << sqrt(phi2phi2(i,j)) << " ";
        }
        cout << endl;
    }


}
Esempio n. 6
0
	C_ListTypeString & operator = (const C_ListTypeString &other) {
		C_ListTypeString tmp_list(other);
		Swap(tmp_list);
		return(*this);
	}