예제 #1
0
void vector_assign(
	vector_expression<V, cpu_tag>& v, vector_expression<E, cpu_tag> const& e, 
	dense_tag, packed_tag
) {
	typedef typename E::const_iterator EIterator;
	typedef typename V::value_type value_type;
	EIterator eiter = e.begin();
	EIterator eend = e.end();
	//special case:
	//right hand side is completely 0
	if(eiter == eend){
		v().clear();
		return;
	}
	EIterator viter = v.begin();
	EIterator vend = v.end();
	
	//set the first elements to zero
	for(;viter.index() != eiter.index(); ++viter){
		*viter= value_type/*zero*/();
	}
	//copy contents of right-hand side
	for(;eiter != eend; ++eiter,++viter){
		*viter= *eiter;
	}
	
	for(;viter!= vend; ++viter){
		*viter= value_type/*zero*/();
	}
}
예제 #2
0
void vector_assign_functor(
	vector_expression<V, cpu_tag>& v,
	vector_expression<E, cpu_tag> const& e,
	F f,
	dense_tag, packed_tag
) {
	typedef typename E::const_iterator EIterator;
	typedef typename V::const_iterator VIterator;
	typedef typename V::value_type value_type;
	EIterator eiter = e().begin();
	EIterator eend = e().end();
	VIterator viter = v().begin();
	VIterator vend = v().end();
	//right hand side hasnonzero elements
	if(eiter != eend){
		//apply f to the first elements for which the right hand side is 0, unless f is the identity
		for(;viter.index() != eiter.index() &&!F::right_zero_identity; ++viter){
			*viter = f(*viter,value_type/*zero*/());
		}
		//copy contents of right-hand side
		for(;eiter != eend; ++eiter,++viter){
			*viter = f(*viter,*eiter);
		}
	}
	//apply f to the last elements for which the right hand side is 0, unless f is the identity
	for(;viter!= vend &&!F::right_zero_identity; ++viter){
		*viter= value_type/*zero*/();
	}
}
예제 #3
0
void assign(
    vector_expression<V>& v, vector_expression<E> const& e,
    dense_random_access_iterator_tag, packed_random_access_iterator_tag
) {
    SIZE_CHECK(v().size() == e().size());
    typedef typename E::const_iterator EIterator;
    typedef typename V::scalar_type scalar_type;
    EIterator eiter = e.begin();
    EIterator eend = e.end();
    //special case:
    //right hand side is completely 0
    if(eiter == eend) {
        v().clear();
        return;
    }
    EIterator viter = v.begin();
    EIterator vend = v.end();

    //set the first elements to zero
    for(; viter.index() != eiter.index(); ++viter) {
        *viter= scalar_type/*zero*/();
    }
    //copy contents of right-hand side
    for(; eiter != eend; ++eiter,++viter) {
        *viter= *eiter;
    }

    for(; viter!= vend; ++viter) {
        *viter= scalar_type/*zero*/();
    }
}
예제 #4
0
void assign(
    vector_expression<V>& v,
    vector_expression<E> const& e,
    F f,
    dense_random_access_iterator_tag, packed_random_access_iterator_tag
) {
    SIZE_CHECK(v().size() == e().size());
    typedef typename E::const_iterator EIterator;
    typedef typename V::const_iterator VIterator;
    typedef typename V::scalar_type scalar_type;
    EIterator eiter = e().begin();
    EIterator eend = e().end();
    VIterator viter = v().begin();
    VIterator vend = v().end();
    //right hand side hasnonzero elements
    if(eiter != eend) {
        //apply f to the first elements for which the right hand side is 0, unless f is the identity
        for(; viter.index() != eiter.index() &&!F::right_zero_identity; ++viter) {
            f(*viter,scalar_type/*zero*/());
        }
        //copy contents of right-hand side
        for(; eiter != eend; ++eiter,++viter) {
            f(*viter,*eiter);
        }
    }
    //apply f to the last elements for which the right hand side is 0, unless f is the identity
    for(; viter!= vend &&!F::right_zero_identity; ++viter) {
        *viter= scalar_type/*zero*/();
    }
}
예제 #5
0
void vector_assign(
	vector_expression<V, cpu_tag>& v, vector_expression<E, cpu_tag> const& e, 
	packed_tag, packed_tag
) {
	typedef typename E::const_iterator EIterator;
	EIterator eiter = e.begin();
	EIterator eend = e.end();
	//special case:
	//right hand side is completely 0
	if(eiter == eend){
		v().clear();
		return;
	}
	EIterator viter = v.begin();
	EIterator vend = v.end();
	
	//check for compatible layout
	REMORA_SIZE_CHECK(vend-viter);//empty ranges can't be compatible
	//check whether the right hand side range is included in the left hand side range
	REMORA_SIZE_CHECK(viter.index() <= eiter.index());
	REMORA_SIZE_CHECK(viter.index()+(vend-viter) >= eiter.index()+(eend-eiter));
	
	//copy contents of right-hand side
	viter += eiter.index()-viter.index();
	for(;eiter != eend; ++eiter,++viter){
		*viter= *eiter;
	}
}
예제 #6
0
void vector_assign_functor(
	vector_expression<V, cpu_tag>& v,
	vector_expression<E, cpu_tag> const& e,
	F f,
	packed_tag, packed_tag
) {
	typedef typename E::const_iterator EIterator;
	typedef typename V::const_iterator VIterator;
	typedef typename V::value_type value_type;
	EIterator eiter = e().begin();
	EIterator eend = e().end();
	VIterator viter = v().begin();
	VIterator vend = v().end();
	
	//right hand side has nonzero elements
	if(eiter != eend){
		
		//check for compatible layout
		REMORA_SIZE_CHECK(vend-viter);//empty ranges can't be compatible
		//check whether the right hand side range is included in the left hand side range
		REMORA_SIZE_CHECK(viter.index() <= eiter.index());
		REMORA_SIZE_CHECK(viter.index()+(vend-viter) >= eiter.index()+(eend-eiter));
		
		//apply f to the first elements for which the right hand side is 0, unless f is the identity
		for(;viter.index() != eiter.index() &&!F::right_zero_identity; ++viter){
			*viter = f(*viter,value_type/*zero*/());
		}
		//copy contents of right-hand side
		for(;eiter != eend; ++eiter,++viter){
			*viter = f(*viter,*eiter);
		}
	}
	//apply f to the last elements for which the right hand side is 0, unless f is the identity
	for(;viter!= vend &&!F::right_zero_identity; ++viter){
		*viter= f(*viter,value_type/*zero*/());
	}
}
예제 #7
0
void assign(
	vector_expression<V>& v,
	vector_expression<E> const& e,
	F f,
	packed_random_access_iterator_tag, packed_random_access_iterator_tag
) {
	SIZE_CHECK(v().size() == e().size());
	typedef typename E::const_iterator EIterator;
	typedef typename V::scalar_type scalar_type;
	EIterator eiter = e.begin();
	EIterator eend = e.end();
	EIterator viter = v.begin();
	EIterator vend = v.end();
	
	//right hand side has nonzero elements
	if(eiter != eend){
		
		//check for compatible layout
		SIZE_CHECK(vend-viter);//empty ranges can't be compatible
		//check whether the right hand side range is included in the left hand side range
		SIZE_CHECK(viter.index() <= eiter.index());
		SIZE_CHECK(viter.index()+(vend-viter) >= eiter.index()+(eend-eiter));
		
		//apply f to the first elements for which the right hand side is 0, unless f is the identity
		for(;viter.index() != eiter.index() &&!F::right_zero_identity; ++viter){
			f(*viter,scalar_type/*zero*/());
		}
		//copy contents of right-hand side
		for(;eiter != eend; ++eiter,++viter){
			f(*viter,*eiter);
		}
	}
	//apply f to the last elements for which the right hand side is 0, unless f is the identity
	for(;viter!= vend &&!F::right_zero_identity; ++viter){
		*viter= scalar_type/*zero*/();
	}
}