#include <iostream>
#include <tools.h>
Go to the source code of this file.
Functions | |
void | print (ex e) |
void | variants (ex e) |
int | main () |
int main | ( | ) |
Definition at line 108 of file ex_inspection.cpp.
References test::e, SyFi::initSyFi(), SyFi::isymb(), variants(), SyFi::x, SyFi::y, and SyFi::z.
00108 { 00109 initSyFi(3); 00110 00111 ex e; 00112 00113 e = x*y+y*z+z*x; 00114 variants(e); 00115 00116 e = pow(x*y+y*z+z*x,5); 00117 variants(e); 00118 00119 e = (x*y*z)*(x*y*z)+(x*y*z)+(x*y*z); 00120 variants(e); 00121 00122 e = pow(2-2*y,3) * pow(1+x*y,2) * pow(x-2*y,2) * (x+y); 00123 variants(e); 00124 00125 e = 1; 00126 for(int i=0; i<10; i++) 00127 { 00128 e = e*isymb("x",i) + isymb("y",i); 00129 } 00130 variants(e); 00131 00132 return 0; 00133 }
void print | ( | ex | e | ) |
Definition at line 26 of file ex_inspection.cpp.
References SyFi::ExStats::adds, SyFi::count_ops(), SyFi::count_symbols(), SyFi::ExStats::flops, SyFi::ExStats::functions, SyFi::ExStats::muls, and SyFi::ExStats::pows.
Referenced by check_CrouzeixRaviart(), main(), and variants().
00027 { 00028 cout << " e = " << e << endl; 00029 00030 exhashmap<int> sc = count_symbols(e); 00031 exhashmap<int>::iterator it; 00032 int count = 0; 00033 int maxcount = 0; 00034 for(it = sc.begin(); it != sc.end(); it++) 00035 { 00036 if(it->second > maxcount) 00037 maxcount = it->second; 00038 count += it->second; 00039 //cout << " " << it->first << ": " << it->second << endl; 00040 } 00041 cout << " number of symbols / total symbol count = " << sc.size() << ", " << count << endl; 00042 00043 ExStats es = count_ops(e); 00044 cout << " m,a,p,f,flops = " 00045 << es.muls << ", " 00046 << es.adds << ", " 00047 << es.pows << ", " 00048 << es.functions << ", " 00049 << es.flops << endl; 00050 }
void variants | ( | ex | e | ) |
Definition at line 52 of file ex_inspection.cpp.
References SyFi::normal(), print(), SyFi::replace_powers(), SyFi::x, SyFi::y, and SyFi::z.
Referenced by main().
00053 { 00054 cout << "====================" << endl; 00055 cout << "original:" << endl; 00056 print(e); 00057 00058 cout << "expand:" << endl; 00059 print(expand(e)); 00060 00061 cout << "normal:" << endl; 00062 print(normal(e)); 00063 00064 cout << "sqrfree in x,y,z:" << endl; 00065 print(sqrfree(e,lst(x,y,z))); 00066 /* 00067 cout << "sqrfree in x,y,z of expanded form:" << endl; 00068 print(sqrfree(expand(e),lst(x,y,z))); 00069 */ 00070 00071 /* 00072 cout << "collect_common_factors:" << endl; 00073 print(collect_common_factors(e)); 00074 00075 cout << "collect_common_factors o expand:" << endl; 00076 print(collect_common_factors(expand(e))); 00077 */ 00078 cout << "----------------------------------------" << endl; 00079 00080 list<symexpair> sel; 00081 list<symbol> sl; 00082 sl.push_back(x); 00083 sl.push_back(y); 00084 sl.push_back(z); 00085 00086 cout << "replace_powers:" << endl; 00087 print( replace_powers(e, sl, sel) ); 00088 00089 cout << "replace_powers(expand):" << endl; 00090 print( replace_powers(expand(e), sl, sel) ); 00091 00092 cout << "replace_powers(sqrfree):" << endl; 00093 print( replace_powers(sqrfree(e, lst(x,y,z)), sl, sel) ); 00094 00095 cout << "replace_powers(sqrfree(expand)):" << endl; 00096 print( replace_powers(sqrfree(expand(e), lst(x,y,z)), sl, sel) ); 00097 cout << "====================" << endl; 00098 00099 /* 00100 list<symexpair>::iterator it = sel.begin(); 00101 for(;it!=sel.end();it++) 00102 { 00103 cout << it->first << ", " << it->second << endl; 00104 } 00105 */ 00106 }