本文整理汇总了C++中DVectorSlice::stride方法的典型用法代码示例。如果您正苦于以下问题:C++ DVectorSlice::stride方法的具体用法?C++ DVectorSlice::stride怎么用?C++ DVectorSlice::stride使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DVectorSlice
的用法示例。
在下文中一共展示了DVectorSlice::stride方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void DenseLinAlgPack::syr2(value_type alpha, const DVectorSlice& vs_rhs1, const DVectorSlice& vs_rhs2
, DMatrixSliceSym* sym_lhs)
{
assert_gms_square(sym_lhs->gms());
VopV_assert_sizes( vs_rhs1.dim(), vs_rhs2.dim() );
MtV_assert_sizes( sym_lhs->gms().rows(), sym_lhs->gms().cols()
, BLAS_Cpp::no_trans, vs_rhs1.dim() );
BLAS_Cpp::syr2( sym_lhs->uplo(), vs_rhs1.dim(), alpha, vs_rhs1.raw_ptr()
, vs_rhs1.stride(), vs_rhs2.raw_ptr(), vs_rhs2.stride()
, sym_lhs->gms().col_ptr(1), sym_lhs->gms().max_rows() );
}
示例2: ger
void DenseLinAlgPack::ger(
value_type alpha, const DVectorSlice& vs_rhs1, const DVectorSlice& vs_rhs2
, DMatrixSlice* gms_lhs )
{
Vp_MtV_assert_sizes( vs_rhs2.dim(), gms_lhs->rows(), gms_lhs->cols()
, BLAS_Cpp::no_trans, vs_rhs1.dim() );
BLAS_Cpp::ger(
gms_lhs->rows(), gms_lhs->cols(), alpha
,vs_rhs1.raw_ptr(), vs_rhs1.stride()
,vs_rhs2.raw_ptr(), vs_rhs2.stride()
,gms_lhs->col_ptr(1), gms_lhs->max_rows() );
}
示例3: Vp_StMtV
void MatrixSymDiagStd::Vp_StMtV(
DVectorSlice* vs_lhs, value_type alpha, BLAS_Cpp::Transp trans_rhs1
, const DVectorSlice& vs_rhs2, value_type beta) const
{
const DVectorSlice diag = this->diag();
size_type n = diag.size();
//
// y = b*y + a * op(A) * x
//
DenseLinAlgPack::Vp_MtV_assert_sizes(
vs_lhs->size(), n, n, trans_rhs1, vs_rhs2.size() );
//
// A is symmetric and diagonal A = diag(diag) so:
//
// y(j) += a * diag(j) * x(j), for j = 1...n
//
if( vs_rhs2.stride() == 1 && vs_lhs->stride() == 1 ) {
// Optimized implementation
const value_type
*d_itr = diag.raw_ptr(),
*x_itr = vs_rhs2.raw_ptr();
value_type
*y_itr = vs_lhs->raw_ptr(),
*y_end = y_itr + vs_lhs->size();
if( beta == 0.0 ) {
while( y_itr != y_end )
*y_itr++ = alpha * (*d_itr++) * (*x_itr++);
}
else if( beta == 1.0 ) {
while( y_itr != y_end )
*y_itr++ += alpha * (*d_itr++) * (*x_itr++);
}
else {
for( ; y_itr != y_end; ++y_itr )
*y_itr = beta * (*y_itr) + alpha * (*d_itr++) * (*x_itr++);
}
}
else {
// Generic implementation
DVectorSlice::const_iterator
d_itr = diag.begin(),
x_itr = vs_rhs2.begin();
DVectorSlice::iterator
y_itr = vs_lhs->begin(),
y_end = vs_lhs->end();
for( ; y_itr != y_end; ++y_itr, ++d_itr, ++x_itr ) {
#ifdef LINALGPACK_CHECK_RANGE
TEST_FOR_EXCEPT( !( d_itr < diag.end() ) );
TEST_FOR_EXCEPT( !( x_itr < vs_rhs2.end() ) );
TEST_FOR_EXCEPT( !( y_itr < vs_lhs->end() ) );
#endif
*y_itr = beta * (*y_itr) + alpha * (*d_itr) * (*x_itr);
}
}
}
示例4: Vp_StMtV
void DenseLinAlgPack::Vp_StMtV(DVectorSlice* vs_lhs, value_type alpha, const DMatrixSlice& gms_rhs1
, BLAS_Cpp::Transp trans_rhs1, const DVectorSlice& vs_rhs2, value_type beta)
{
Vp_MtV_assert_sizes(vs_lhs->dim(), gms_rhs1.rows() , gms_rhs1.cols(), trans_rhs1
, vs_rhs2.dim());
BLAS_Cpp::gemv(trans_rhs1,gms_rhs1.rows(),gms_rhs1.cols(),alpha,gms_rhs1.col_ptr(1)
,gms_rhs1.max_rows(), vs_rhs2.raw_ptr(),vs_rhs2.stride(),beta,vs_lhs->raw_ptr()
,vs_lhs->stride());
}
示例5: V_InvMtV
void MatrixSymDiagStd::V_InvMtV(
DVectorSlice* vs_lhs, BLAS_Cpp::Transp trans_rhs1
, const DVectorSlice& vs_rhs2) const
{
const DVectorSlice diag = this->diag();
size_type n = diag.size();
// y = inv(op(A)) * x
//
// A is symmetric and diagonal (A = diag(diag)) so:
//
// y(j) = x(j) / diag(j), for j = 1...n
DenseLinAlgPack::Vp_MtV_assert_sizes( vs_lhs->size()
, n, n, trans_rhs1, vs_rhs2.size() );
if( vs_rhs2.stride() == 1 && vs_lhs->stride() == 1 ) {
// Optimized implementation
const value_type
*d_itr = diag.raw_ptr(),
*x_itr = vs_rhs2.raw_ptr();
value_type
*y_itr = vs_lhs->raw_ptr(),
*y_end = y_itr + vs_lhs->size();
while( y_itr != y_end )
*y_itr++ = (*x_itr++) / (*d_itr++);
}
else {
// Generic implementation
DVectorSlice::const_iterator
d_itr = diag.begin(),
x_itr = vs_rhs2.begin();
DVectorSlice::iterator
y_itr = vs_lhs->begin(),
y_end = vs_lhs->end();
for( ; y_itr != y_end; ++y_itr, ++d_itr, ++x_itr ) {
TEST_FOR_EXCEPT( !( d_itr < diag.end() ) );
TEST_FOR_EXCEPT( !( x_itr < vs_rhs2.end() ) );
TEST_FOR_EXCEPT( !( y_itr < vs_lhs->end() ) );
*y_itr = (*x_itr)/(*d_itr);
}
}
}