本文整理汇总了C++中sequence::buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ sequence::buffer方法的具体用法?C++ sequence::buffer怎么用?C++ sequence::buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sequence
的用法示例。
在下文中一共展示了sequence::buffer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conv
sequence<R> operator*( const sequence<T1> &X, const sequence<T2> &Y )
{
if( X.size()==0 || Y.size()==0 )
return sequence<R>();
vec<R> vec = conv( X.buffer(), Y.buffer() );
int t1 = X.t1() + Y.t1();
return sequence<R>( vec, t1 );
}
示例2: decltype
sequence<decltype(T()*S())> element_prod( const sequence<T>& X, const sequence<S>& Y )
{
typedef decltype(T()*S()) R;
// If any vector is empty
if( X.size() == 0 || Y.size() == 0 )
return sequence<R>();
// Overlapping interval
int ta = max(X.t1(),Y.t1());
int tb = min(X.t2(),Y.t2());
// If they do not overlap
if( ta > tb )
return sequence<R>();
// They do overlap
vec<R> v = element_prod(
X.buffer()( range( ta-X.t1(), tb-X.t1()+1 ) ),
Y.buffer()( range( ta-Y.t1(), tb-Y.t1()+1 ) ) );
return sequence<R>( v, ta );
}
示例3: if
sequence<R> operator+( sequence<T1> X, sequence<T2> Y )
{
if( X.size() == 0 )
return Y;
if( Y.size() == 0 )
return X;
// Intervals
int t1 = min(X.t1(),Y.t1());
int ta = max(X.t1(),Y.t1());
int tb = min(X.t2(),Y.t2());
int t2 = max(X.t2(),Y.t2());
int sx = X.size();
int sy = Y.size();
// First interval
vec<R> v1(0);
if( t1 == X.t1() && t1 != Y.t1() )
v1 = X.buffer()( range( 0, min(ta-X.t1(),sx) ) );
else if( t1 != X.t1() && t1 == Y.t1() )
v1 = Y.buffer()( range( 0, min(ta-Y.t1(),sy) ) );
// Second interval
vec<R> v2;
if( ta <= tb )
v2 = X.buffer()( range( ta-X.t1(), tb-X.t1()+1 ) ) + Y.buffer()( range( ta-Y.t1(), tb-Y.t1()+1 ) );
else {
int I = ta-tb-1;
v2.resize(I);
for( int i = 0; i < I; i++ )
v2(i) = 0*X.buffer()(0);
}
// Third interval
vec<R> v3(0);
if( t2 == X.t2() && t2 != Y.t2() )
v3 = X.buffer()( range( max(tb-X.t1()+1,0), X.size() ) );
else if( t2 != X.t2() && t2 == Y.t2() )
v3 = Y.buffer()( range( max(tb-Y.t1()+1,0), Y.size() ) );
// Sum
return sequence<R>( vec<R>{v1,v2,v3}, t1 );
}
示例4:
// class R = decltype( noproxy(T1()*T2()) ),
// class = typename enable_if<
// is_convertible<T2,T1>::value
// >::type >
sequence<R> operator*( const sequence<T1> &X, const T2 &a )
{
return sequence<R>( X.buffer()*a, X.t1() );
}
示例5: norm
double norm(const sequence<T> &X, double p=2 )
{
return norm( X.buffer(), p );
}