|
GiNaC
1.6.2
|
00001 00006 /* 00007 * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #include "ex.h" 00025 #include "numeric.h" 00026 #include "utils.h" 00027 #include "version.h" 00028 00029 namespace GiNaC { 00030 00031 /* Version information buried into the library */ 00032 const int version_major = GINACLIB_MAJOR_VERSION; 00033 const int version_minor = GINACLIB_MINOR_VERSION; 00034 const int version_micro = GINACLIB_MICRO_VERSION; 00035 00036 00038 pole_error::pole_error(const std::string& what_arg, int degree) 00039 : domain_error(what_arg), deg(degree) { } 00040 00042 int pole_error::degree() const 00043 { 00044 return deg; 00045 } 00046 00048 unsigned log2(unsigned n) 00049 { 00050 unsigned k; 00051 for (k = 0; n > 1; n >>= 1) 00052 ++k; 00053 return k; 00054 } 00055 00056 00058 // flyweight chest of numbers is initialized here: 00060 00063 int library_init::count = 0; 00064 00065 // static numeric -120 00066 const numeric *_num_120_p; 00067 const ex _ex_120 = _ex_120; 00068 00069 // static numeric -60 00070 const numeric *_num_60_p; 00071 const ex _ex_60 = _ex_60; 00072 00073 // static numeric -48 00074 const numeric *_num_48_p; 00075 const ex _ex_48 = _ex_48; 00076 00077 // static numeric -30 00078 const numeric *_num_30_p; 00079 const ex _ex_30 = _ex_30; 00080 00081 // static numeric -25 00082 const numeric *_num_25_p; 00083 const ex _ex_25 = _ex_25; 00084 00085 // static numeric -24 00086 const numeric *_num_24_p; 00087 const ex _ex_24 = _ex_24; 00088 00089 // static numeric -20 00090 const numeric *_num_20_p; 00091 const ex _ex_20 = _ex_20; 00092 00093 // static numeric -18 00094 const numeric *_num_18_p; 00095 const ex _ex_18 = _ex_18; 00096 00097 // static numeric -15 00098 const numeric *_num_15_p; 00099 const ex _ex_15 = _ex_15; 00100 00101 // static numeric -12 00102 const numeric *_num_12_p; 00103 const ex _ex_12 = _ex_12; 00104 00105 // static numeric -11 00106 const numeric *_num_11_p; 00107 const ex _ex_11 = _ex_11; 00108 00109 // static numeric -10 00110 const numeric *_num_10_p; 00111 const ex _ex_10 = _ex_10; 00112 00113 // static numeric -9 00114 const numeric *_num_9_p; 00115 const ex _ex_9 = _ex_9; 00116 00117 // static numeric -8 00118 const numeric *_num_8_p; 00119 const ex _ex_8 = _ex_8; 00120 00121 // static numeric -7 00122 const numeric *_num_7_p; 00123 const ex _ex_7 = _ex_7; 00124 00125 // static numeric -6 00126 const numeric *_num_6_p; 00127 const ex _ex_6 = _ex_6; 00128 00129 // static numeric -5 00130 const numeric *_num_5_p; 00131 const ex _ex_5 = _ex_5; 00132 00133 // static numeric -4 00134 const numeric *_num_4_p; 00135 const ex _ex_4 = _ex_4; 00136 00137 // static numeric -3 00138 const numeric *_num_3_p; 00139 const ex _ex_3 = _ex_3; 00140 00141 // static numeric -2 00142 const numeric *_num_2_p; 00143 const ex _ex_2 = _ex_2; 00144 00145 // static numeric -1 00146 const numeric *_num_1_p; 00147 const ex _ex_1 = _ex_1; 00148 00149 // static numeric -1/2 00150 const numeric *_num_1_2_p; 00151 const ex _ex_1_2= _ex_1_2; 00152 00153 // static numeric -1/3 00154 const numeric *_num_1_3_p; 00155 const ex _ex_1_3= _ex_1_3; 00156 00157 // static numeric -1/4 00158 const numeric *_num_1_4_p; 00159 const ex _ex_1_4= _ex_1_4; 00160 00161 // static numeric 0 00162 const numeric *_num0_p; 00163 const basic *_num0_bp; 00164 const ex _ex0 = _ex0; 00165 00166 // static numeric 1/4 00167 const numeric *_num1_4_p; 00168 const ex _ex1_4 = _ex1_4; 00169 00170 // static numeric 1/3 00171 const numeric *_num1_3_p; 00172 const ex _ex1_3 = _ex1_3; 00173 00174 // static numeric 1/2 00175 const numeric *_num1_2_p; 00176 const ex _ex1_2 = _ex1_2; 00177 00178 // static numeric 1 00179 const numeric *_num1_p; 00180 const ex _ex1 = _ex1; 00181 00182 // static numeric 2 00183 const numeric *_num2_p; 00184 const ex _ex2 = _ex2; 00185 00186 // static numeric 3 00187 const numeric *_num3_p; 00188 const ex _ex3 = _ex3; 00189 00190 // static numeric 4 00191 const numeric *_num4_p; 00192 const ex _ex4 = _ex4; 00193 00194 // static numeric 5 00195 const numeric *_num5_p; 00196 const ex _ex5 = _ex5; 00197 00198 // static numeric 6 00199 const numeric *_num6_p; 00200 const ex _ex6 = _ex6; 00201 00202 // static numeric 7 00203 const numeric *_num7_p; 00204 const ex _ex7 = _ex7; 00205 00206 // static numeric 8 00207 const numeric *_num8_p; 00208 const ex _ex8 = _ex8; 00209 00210 // static numeric 9 00211 const numeric *_num9_p; 00212 const ex _ex9 = _ex9; 00213 00214 // static numeric 10 00215 const numeric *_num10_p; 00216 const ex _ex10 = _ex10; 00217 00218 // static numeric 11 00219 const numeric *_num11_p; 00220 const ex _ex11 = _ex11; 00221 00222 // static numeric 12 00223 const numeric *_num12_p; 00224 const ex _ex12 = _ex12; 00225 00226 // static numeric 15 00227 const numeric *_num15_p; 00228 const ex _ex15 = _ex15; 00229 00230 // static numeric 18 00231 const numeric *_num18_p; 00232 const ex _ex18 = _ex18; 00233 00234 // static numeric 20 00235 const numeric *_num20_p; 00236 const ex _ex20 = _ex20; 00237 00238 // static numeric 24 00239 const numeric *_num24_p; 00240 const ex _ex24 = _ex24; 00241 00242 // static numeric 25 00243 const numeric *_num25_p; 00244 const ex _ex25 = _ex25; 00245 00246 // static numeric 30 00247 const numeric *_num30_p; 00248 const ex _ex30 = _ex30; 00249 00250 // static numeric 48 00251 const numeric *_num48_p; 00252 const ex _ex48 = _ex48; 00253 00254 // static numeric 60 00255 const numeric *_num60_p; 00256 const ex _ex60 = _ex60; 00257 00258 // static numeric 120 00259 const numeric *_num120_p; 00260 const ex _ex120 = _ex120; 00261 00264 library_init::library_init() 00265 { 00266 if (count++==0) { 00267 (_num_120_p = new numeric(-120))->setflag(status_flags::dynallocated); 00268 (_num_60_p = new numeric(-60))->setflag(status_flags::dynallocated); 00269 (_num_48_p = new numeric(-48))->setflag(status_flags::dynallocated); 00270 (_num_30_p = new numeric(-30))->setflag(status_flags::dynallocated); 00271 (_num_25_p = new numeric(-25))->setflag(status_flags::dynallocated); 00272 (_num_24_p = new numeric(-24))->setflag(status_flags::dynallocated); 00273 (_num_20_p = new numeric(-20))->setflag(status_flags::dynallocated); 00274 (_num_18_p = new numeric(-18))->setflag(status_flags::dynallocated); 00275 (_num_15_p = new numeric(-15))->setflag(status_flags::dynallocated); 00276 (_num_12_p = new numeric(-12))->setflag(status_flags::dynallocated); 00277 (_num_11_p = new numeric(-11))->setflag(status_flags::dynallocated); 00278 (_num_10_p = new numeric(-10))->setflag(status_flags::dynallocated); 00279 (_num_9_p = new numeric(-9))->setflag(status_flags::dynallocated); 00280 (_num_8_p = new numeric(-8))->setflag(status_flags::dynallocated); 00281 (_num_7_p = new numeric(-7))->setflag(status_flags::dynallocated); 00282 (_num_6_p = new numeric(-6))->setflag(status_flags::dynallocated); 00283 (_num_5_p = new numeric(-5))->setflag(status_flags::dynallocated); 00284 (_num_4_p = new numeric(-4))->setflag(status_flags::dynallocated); 00285 (_num_3_p = new numeric(-3))->setflag(status_flags::dynallocated); 00286 (_num_2_p = new numeric(-2))->setflag(status_flags::dynallocated); 00287 (_num_1_p = new numeric(-1))->setflag(status_flags::dynallocated); 00288 (_num_1_2_p = new numeric(-1,2))->setflag(status_flags::dynallocated); 00289 (_num_1_3_p = new numeric(-1,3))->setflag(status_flags::dynallocated); 00290 (_num_1_4_p = new numeric(-1,4))->setflag(status_flags::dynallocated); 00291 (_num0_p = new numeric(0))->setflag(status_flags::dynallocated); 00292 _num0_bp = _num0_p; // Cf. class ex default ctor. 00293 (_num1_4_p = new numeric(1,4))->setflag(status_flags::dynallocated); 00294 (_num1_3_p = new numeric(1,3))->setflag(status_flags::dynallocated); 00295 (_num1_2_p = new numeric(1,2))->setflag(status_flags::dynallocated); 00296 (_num1_p = new numeric(1))->setflag(status_flags::dynallocated); 00297 (_num2_p = new numeric(2))->setflag(status_flags::dynallocated); 00298 (_num3_p = new numeric(3))->setflag(status_flags::dynallocated); 00299 (_num4_p = new numeric(4))->setflag(status_flags::dynallocated); 00300 (_num5_p = new numeric(5))->setflag(status_flags::dynallocated); 00301 (_num6_p = new numeric(6))->setflag(status_flags::dynallocated); 00302 (_num7_p = new numeric(7))->setflag(status_flags::dynallocated); 00303 (_num8_p = new numeric(8))->setflag(status_flags::dynallocated); 00304 (_num9_p = new numeric(9))->setflag(status_flags::dynallocated); 00305 (_num10_p = new numeric(10))->setflag(status_flags::dynallocated); 00306 (_num11_p = new numeric(11))->setflag(status_flags::dynallocated); 00307 (_num12_p = new numeric(12))->setflag(status_flags::dynallocated); 00308 (_num15_p = new numeric(15))->setflag(status_flags::dynallocated); 00309 (_num18_p = new numeric(18))->setflag(status_flags::dynallocated); 00310 (_num20_p = new numeric(20))->setflag(status_flags::dynallocated); 00311 (_num24_p = new numeric(24))->setflag(status_flags::dynallocated); 00312 (_num25_p = new numeric(25))->setflag(status_flags::dynallocated); 00313 (_num30_p = new numeric(30))->setflag(status_flags::dynallocated); 00314 (_num48_p = new numeric(48))->setflag(status_flags::dynallocated); 00315 (_num60_p = new numeric(60))->setflag(status_flags::dynallocated); 00316 (_num120_p = new numeric(120))->setflag(status_flags::dynallocated); 00317 00318 new((void*)&_ex_120) ex(*_num_120_p); 00319 new((void*)&_ex_60) ex(*_num_60_p); 00320 new((void*)&_ex_48) ex(*_num_48_p); 00321 new((void*)&_ex_30) ex(*_num_30_p); 00322 new((void*)&_ex_25) ex(*_num_25_p); 00323 new((void*)&_ex_24) ex(*_num_24_p); 00324 new((void*)&_ex_20) ex(*_num_20_p); 00325 new((void*)&_ex_18) ex(*_num_18_p); 00326 new((void*)&_ex_15) ex(*_num_15_p); 00327 new((void*)&_ex_12) ex(*_num_12_p); 00328 new((void*)&_ex_11) ex(*_num_11_p); 00329 new((void*)&_ex_10) ex(*_num_10_p); 00330 new((void*)&_ex_9) ex(*_num_9_p); 00331 new((void*)&_ex_8) ex(*_num_8_p); 00332 new((void*)&_ex_7) ex(*_num_7_p); 00333 new((void*)&_ex_6) ex(*_num_6_p); 00334 new((void*)&_ex_5) ex(*_num_5_p); 00335 new((void*)&_ex_4) ex(*_num_4_p); 00336 new((void*)&_ex_3) ex(*_num_3_p); 00337 new((void*)&_ex_2) ex(*_num_2_p); 00338 new((void*)&_ex_1) ex(*_num_1_p); 00339 new((void*)&_ex_1_2) ex(*_num_1_2_p); 00340 new((void*)&_ex_1_3) ex(*_num_1_3_p); 00341 new((void*)&_ex_1_4) ex(*_num_1_4_p); 00342 new((void*)&_ex0) ex(*_num0_p); 00343 new((void*)&_ex1_4) ex(*_num1_4_p); 00344 new((void*)&_ex1_3) ex(*_num1_3_p); 00345 new((void*)&_ex1_2) ex(*_num1_2_p); 00346 new((void*)&_ex1) ex(*_num1_p); 00347 new((void*)&_ex2) ex(*_num2_p); 00348 new((void*)&_ex3) ex(*_num3_p); 00349 new((void*)&_ex4) ex(*_num4_p); 00350 new((void*)&_ex5) ex(*_num5_p); 00351 new((void*)&_ex6) ex(*_num6_p); 00352 new((void*)&_ex7) ex(*_num7_p); 00353 new((void*)&_ex8) ex(*_num8_p); 00354 new((void*)&_ex9) ex(*_num9_p); 00355 new((void*)&_ex10) ex(*_num10_p); 00356 new((void*)&_ex11) ex(*_num11_p); 00357 new((void*)&_ex12) ex(*_num12_p); 00358 new((void*)&_ex15) ex(*_num15_p); 00359 new((void*)&_ex18) ex(*_num18_p); 00360 new((void*)&_ex20) ex(*_num20_p); 00361 new((void*)&_ex24) ex(*_num24_p); 00362 new((void*)&_ex25) ex(*_num25_p); 00363 new((void*)&_ex30) ex(*_num30_p); 00364 new((void*)&_ex48) ex(*_num48_p); 00365 new((void*)&_ex60) ex(*_num60_p); 00366 new((void*)&_ex120) ex(*_num120_p); 00367 00368 // Initialize print context class info (this is not strictly necessary 00369 // but we do it anyway to make print_context_class_info::dump_hierarchy() 00370 // output the whole hierarchy whether or not the classes are actually 00371 // used) 00372 print_context::get_class_info_static(); 00373 print_dflt::get_class_info_static(); 00374 print_latex::get_class_info_static(); 00375 print_python::get_class_info_static(); 00376 print_python_repr::get_class_info_static(); 00377 print_tree::get_class_info_static(); 00378 print_csrc::get_class_info_static(); 00379 print_csrc_float::get_class_info_static(); 00380 print_csrc_double::get_class_info_static(); 00381 print_csrc_cl_N::get_class_info_static(); 00382 } 00383 } 00384 00385 00388 library_init::~library_init() 00389 { 00390 if (--count==0) { 00391 // It's really necessary to clean up, since the program 00392 // lifetime might not be the same as libginac.{so,dll} one 00393 // (e.g. consider // dlopen/dlsym/dlclose sequence). 00394 // Let the ex dtors care for deleting the numerics! 00395 _ex120.~ex(); 00396 _ex_120.~ex(); 00397 _ex60.~ex(); 00398 _ex_60.~ex(); 00399 _ex48.~ex(); 00400 _ex_48.~ex(); 00401 _ex30.~ex(); 00402 _ex_30.~ex(); 00403 _ex25.~ex(); 00404 _ex_25.~ex(); 00405 _ex24.~ex(); 00406 _ex_24.~ex(); 00407 _ex20.~ex(); 00408 _ex_20.~ex(); 00409 _ex18.~ex(); 00410 _ex_18.~ex(); 00411 _ex15.~ex(); 00412 _ex_15.~ex(); 00413 _ex12.~ex(); 00414 _ex_12.~ex(); 00415 _ex11.~ex(); 00416 _ex_11.~ex(); 00417 _ex10.~ex(); 00418 _ex_10.~ex(); 00419 _ex9.~ex(); 00420 _ex_9.~ex(); 00421 _ex8.~ex(); 00422 _ex_8.~ex(); 00423 _ex7.~ex(); 00424 _ex_7.~ex(); 00425 _ex6.~ex(); 00426 _ex_6.~ex(); 00427 _ex5.~ex(); 00428 _ex_5.~ex(); 00429 _ex4.~ex(); 00430 _ex_4.~ex(); 00431 _ex3.~ex(); 00432 _ex_3.~ex(); 00433 _ex2.~ex(); 00434 _ex_2.~ex(); 00435 _ex1.~ex(); 00436 _ex_1.~ex(); 00437 _ex1_2.~ex(); 00438 _ex_1_2.~ex(); 00439 _ex1_3.~ex(); 00440 _ex_1_3.~ex(); 00441 _ex1_4.~ex(); 00442 _ex_1_4.~ex(); 00443 _ex0.~ex(); 00444 } 00445 } 00446 00447 void library_init::init_unarchivers() { } 00448 00449 // comment skeleton for header files 00450 00451 00452 // member functions 00453 00454 // default constructor, destructor, copy constructor and assignment operator 00455 // none 00456 00457 // other constructors 00458 // none 00459 00460 // functions overriding virtual functions from base classes 00461 // none 00462 00463 // new virtual functions which can be overridden by derived classes 00464 // none 00465 00466 // non-virtual functions in this class 00467 // none 00468 00469 // member variables 00470 // none 00471 00472 00473 00474 // comment skeleton for implementation files 00475 00476 00478 // default constructor, destructor, copy constructor and assignment operator 00480 00481 // public 00482 // protected 00483 00485 // other constructors 00487 00488 // public 00489 // none 00490 00492 // functions overriding virtual functions from base classes 00494 00495 // public 00496 // protected 00497 // none 00498 00500 // new virtual functions which can be overridden by derived classes 00502 00503 // public 00504 // protected 00505 // none 00506 00508 // non-virtual functions in this class 00510 00511 // public 00512 // protected 00513 // none 00514 00516 // static member variables 00518 00519 // protected 00520 // private 00521 // none 00522 00523 00524 } // namespace GiNaC