本文整理汇总了C++中sequence::t2方法的典型用法代码示例。如果您正苦于以下问题:C++ sequence::t2方法的具体用法?C++ sequence::t2怎么用?C++ sequence::t2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sequence
的用法示例。
在下文中一共展示了sequence::t2方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: adjoint
sequence<T> adjoint( sequence<T> X )
{
int t1 = X.t1();
int t2 = X.t2();
for( int t = t1; t <= t2; t++ )
X(t) = adjoint(X(t));
return X.timereverse();
}
示例2: inner_prod
complex inner_prod(const sequence<T> &X, const sequence<T> &Y )
{
// If any vector is empty
if( X.size() == 0 || Y.size() == 0 )
return 0;
// 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 0;
// They do overlap
complex r = 0;
for( int t = ta; t <= tb; t++ )
r += inner_prod( X(t), Y(t) );
return r;
}
示例3: 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 );
}
示例4: 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 );
}