本文整理汇总了C++中ginac::ex::conjugate方法的典型用法代码示例。如果您正苦于以下问题:C++ ex::conjugate方法的具体用法?C++ ex::conjugate怎么用?C++ ex::conjugate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ginac::ex
的用法示例。
在下文中一共展示了ex::conjugate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvalExpression
void Attribute::EvalExpression () {
if (m_formula.empty()) return;
//strings: simply replace attribute symbol by its value
if (GetTypeID()==typeid(std::string*).name()) {
std::string expr = m_formula;
for (unsigned int i=0; i<m_subjects.size() ; i++) {
Attribute* a = m_subjects.at(i);
stringstream key;
if (a->GetTypeID()==typeid( double*).name()) key << a->GetMember <double>() ;
if (a->GetTypeID()==typeid( int*).name()) key << a->GetMember <int>() ;
if (a->GetTypeID()==typeid( long*).name()) key << a->GetMember <long>() ;
if (a->GetTypeID()==typeid(unsigned*).name()) key << a->GetMember<unsigned>() ;
if (a->GetTypeID()==typeid( bool*).name()) key << a->GetMember <bool>() ;
std::string SymbolName = a->GetPrototype()->GetName() + "x" + a->GetName();
Prototype::ReplaceString(expr,SymbolName,key.str());
}
WriteMember(expr);
//if (GetName()=="Filename") cout << " Eval: " << expr << endl;
return;
}
//collect symbols and corresponding member-values from observed attributes
GiNaC::lst numlist;
for (unsigned int i=0; i<m_subjects.size() ; i++) {
Attribute* a = m_subjects.at(i);
if (a->GetTypeID()==typeid( double*).name()) { numlist.append(a->GetMember <double>() ); continue; }
if (a->GetTypeID()==typeid( int*).name()) { numlist.append(a->GetMember <int>() ); continue; }
if (a->GetTypeID()==typeid( long*).name()) { numlist.append(a->GetMember <long>() ); continue; }
if (a->GetTypeID()==typeid(unsigned*).name()) { numlist.append(a->GetMember<unsigned>() ); continue; }
if (a->GetTypeID()==typeid( bool*).name()) { numlist.append(a->GetMember <bool>() ); continue; }
}
//numeric evaluation of GiNaC expression
GiNaC::ex e = m_expression.subs(m_symlist,numlist);
m_static_vector = m_prototype->GetVector(); // static pointer to evaluate the Vector function
e = GiNaC::evalf(e);
double d = 0.0;
if (GiNaC::is_a<GiNaC::numeric>(e)) {
if ( m_complex ) m_imaginary = -0.5 * GiNaC::ex_to<GiNaC::numeric>( (e-e.conjugate())*GiNaC::I ).to_double();
d = GiNaC::ex_to<GiNaC::numeric>( e ).to_double();//default is real-part
}
//overwrite private member
if (m_datatype==typeid( double*).name() ) WriteMember((double) d );
if (m_datatype==typeid( int*).name() ) WriteMember((int) d );
if (m_datatype==typeid( long*).name() ) WriteMember((long) d );
if (m_datatype==typeid(unsigned*).name() ) WriteMember((unsigned) d );
if (m_datatype==typeid( bool*).name() ) WriteMember((bool) d );
// for dynamic change of runtime compiled attributes after notification!
if (m_ginac_excomp && m_cur_fp==m_num_fp && m_num_fp>0) {
//cout << "!!! " << GetName() << " : NFP =" << GetNumberFunctionPointers() << endl;
//cout << "!!! " << GetName() << " : CFP =" << GetCurrentFunctionPointer() << endl;
//cout << "!!! " << GetName() << " : size=" << m_compiled.size() << endl;
if (m_compiled.size() == m_cur_fp ) m_compiled.push_back(false);
}
}