本文整理汇总了C++中stokhos::OrthogPolyApprox::coeff方法的典型用法代码示例。如果您正苦于以下问题:C++ OrthogPolyApprox::coeff方法的具体用法?C++ OrthogPolyApprox::coeff怎么用?C++ OrthogPolyApprox::coeff使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类stokhos::OrthogPolyApprox
的用法示例。
在下文中一共展示了OrthogPolyApprox::coeff方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Stokhos::QuadOrthogPolyExpansion<ordinal_type, value_type>::
minus(Stokhos::OrthogPolyApprox<ordinal_type, value_type>& c,
const Stokhos::OrthogPolyApprox<ordinal_type, value_type>& a,
const Stokhos::OrthogPolyApprox<ordinal_type, value_type>& b)
{
ordinal_type pa = a.size();
ordinal_type pb = b.size();
ordinal_type pc = pa > pb ? pa : pb;
if (c.size() != pc)
c.resize(pc);
const value_type* ca = a.coeff();
const value_type* cb = b.coeff();
value_type* cc = c.coeff();
if (pa > pb) {
for (ordinal_type i=0; i<pb; i++)
cc[i] = ca[i] - cb[i];
for (ordinal_type i=pb; i<pc; i++)
cc[i] = ca[i];
}
else {
for (ordinal_type i=0; i<pa; i++)
cc[i] = ca[i] - cb[i];
for (ordinal_type i=pa; i<pc; i++)
cc[i] = -cb[i];
}
}
示例2: if
void
Stokhos::QuadOrthogPolyExpansion<ordinal_type, value_type>::
timesEqual(Stokhos::OrthogPolyApprox<ordinal_type, value_type>& c,
const Stokhos::OrthogPolyApprox<ordinal_type, value_type>& x)
{
if (use_quad_for_times) {
binary_op(times_quad_func(), c, c, x);
return;
}
ordinal_type p = c.size();
ordinal_type xp = x.size();
ordinal_type pc;
if (p > 1 && xp > 1)
pc = sz;
else
pc = p*xp;
TEST_FOR_EXCEPTION(sz < pc, std::logic_error,
"Stokhos::QuadOrthogPolyExpansion::timesEqual()" <<
": Expansion size (" << sz <<
") is too small for computation.");
if (c.size() != pc)
c.resize(pc);
value_type* cc = c.coeff();
const value_type* xc = x.coeff();
if (p > 1 && xp > 1) {
// Copy c coefficients into temporary array
value_type* tc = Stokhos::ds_array<value_type>::get_and_fill(cc,p);
value_type tmp, cijk;
ordinal_type i,j;
for (ordinal_type k=0; k<pc; k++) {
tmp = value_type(0.0);
ordinal_type n = Cijk->num_values(k);
for (ordinal_type l=0; l<n; l++) {
Cijk->value(k,l,i,j,cijk);
if (i < p && j < xp)
tmp += cijk*tc[i]*xc[j];
}
cc[k] = tmp / basis->norm_squared(k);
}
}
else if (p > 1) {
for (ordinal_type i=0; i<p; i++)
cc[i] *= xc[0];
}
else if (xp > 1) {
for (ordinal_type i=1; i<xp; i++)
cc[i] = cc[0]*xc[i];
cc[0] *= xc[0];
}
else {
cc[0] *= xc[0];
}
}
示例3: index
void
Stokhos::CGDivisionExpansionStrategy<ordinal_type,value_type,node_type>::
divide(Stokhos::OrthogPolyApprox<ordinal_type, value_type, node_type>& c,
const value_type& alpha,
const Stokhos::OrthogPolyApprox<ordinal_type, value_type, node_type>& a,
const Stokhos::OrthogPolyApprox<ordinal_type, value_type, node_type>& b,
const value_type& beta)
{
#ifdef STOKHOS_TEUCHOS_TIME_MONITOR
TEUCHOS_FUNC_TIME_MONITOR("Stokhos::CGDivisionStrategy::divide()");
#endif
ordinal_type sz = basis->size();
ordinal_type pa = a.size();
ordinal_type pb = b.size();
ordinal_type pc;
if (pb > 1)
pc = sz;
else
pc = pa;
if (c.size() != pc)
c.resize(pc);
const value_type* ca = a.coeff();
const value_type* cb = b.coeff();
value_type* cc = c.coeff();
if (pb > 1) {
// Compute A
A->putScalar(0.0);
typename Cijk_type::k_iterator k_begin = Cijk->k_begin();
typename Cijk_type::k_iterator k_end = Cijk->k_end();
if (pb < Cijk->num_k())
k_end = Cijk->find_k(pb);
value_type cijk;
ordinal_type i,j,k;
for (typename Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
k = index(k_it);
for (typename Cijk_type::kj_iterator j_it = Cijk->j_begin(k_it);
j_it != Cijk->j_end(k_it); ++j_it) {
j = index(j_it);
for (typename Cijk_type::kji_iterator i_it = Cijk->i_begin(j_it);
i_it != Cijk->i_end(j_it); ++i_it) {
i = index(i_it);
cijk = value(i_it);
(*A)(i,j) += cijk*cb[k];
}
}
}
// Compute B
B->putScalar(0.0);
for (ordinal_type i=0; i<pa; i++)
(*B)(i,0) = ca[i]*basis->norm_squared(i);
Teuchos::SerialDenseMatrix<ordinal_type,value_type> D(sz, 1);
//Equilibrate the linear system
if (equil == 1){
//Create diag mtx of max row entries
for (ordinal_type i=0; i<sz; i++){
Teuchos::SerialDenseMatrix<ordinal_type, value_type> r(Teuchos::View, *A, 1, sz, i, 0);
D(i,0)=sqrt(r.normOne());
}
//Compute inv(D)*A*inv(D)
for (ordinal_type i=0; i<sz; i++){
for (ordinal_type j=0; j<sz; j++){
(*A)(i,j)=(*A)(i,j)/(D(i,0)*D(j,0));
}
}
//Scale b by inv(D)
for (ordinal_type i=0; i<sz; i++){
(*B)(i,0)=(*B)(i,0)/D(i,0);
}
}
if (linear == 1){
//Compute M, the linear matrix to be used in the preconditioner
pb = basis->dimension()+1;
M->putScalar(0.0);
if (pb < Cijk->num_k())
k_end = Cijk->find_k(pb);
for (typename Cijk_type::k_iterator k_it=k_begin; k_it!=k_end; ++k_it) {
k = index(k_it);
for ( typename Cijk_type::kj_iterator j_it = Cijk->j_begin(k_it);
j_it != Cijk->j_end(k_it); ++j_it) {
j = index(j_it);
for ( typename Cijk_type::kji_iterator i_it = Cijk->i_begin(j_it);
i_it != Cijk->i_end(j_it); ++i_it) {
i = index(i_it);
//.........这里部分代码省略.........