00001 00002 00003 // Addmul and submul algorithm selectors 00004 inline void N::addmul(const N& a, const limb_t b) 00005 { 00006 if(size) 00007 { 00008 if(a.size) 00009 { 00010 addmul_large_large(a, b); 00011 } 00012 else 00013 { 00014 addmul_large_small(a.limb, b); 00015 } 00016 } 00017 else 00018 { 00019 if(a.size) 00020 { 00021 addmul_small_large(a, b); 00022 } 00023 else 00024 { 00025 addmul_small_small(a.limb, b); 00026 } 00027 } 00028 } 00029 00030 inline void N::submul(const N& a, const limb_t b) 00031 { 00032 if(size) 00033 { 00034 if(a.size) 00035 { 00036 submul_large_large(a, b); 00037 } 00038 else 00039 { 00040 submul_large_small(a.limb, b); 00041 } 00042 } 00043 else 00044 { 00045 if(a.size) 00046 { 00047 submul_small_large(a, b); 00048 } 00049 else 00050 { 00051 submul_small_small(a.limb, b); 00052 } 00053 } 00054 } 00055 00056 // Addmul and submul algorithms 00057 00058 inline void N::addmul_small_small(const limb_t a, const limb_t b) 00059 { 00060 limb_t lo, hi, old; 00061 asm("mulq %3" : "=a"(lo), "=d"(hi) : "a"(a), "rm"(b)); 00062 old = limb; 00063 limb += lo; 00064 if(limb < lo || limb < old) 00065 { 00066 hi++; 00067 } 00068 if(hi == 0) 00069 { 00070 reserve(0); 00071 limb = lo; 00072 } 00073 else 00074 { 00075 reserve(1); 00076 data[0] = lo; 00077 data[1] = hi; 00078 } 00079 } 00080 00081 inline void N::submul_small_small(const limb_t a, const limb_t b) 00082 { 00083 } 00084
Copyright © 2007-2008 Remco Bloemen.
Generated on Tue Jan 22 17:35:31 2008 for symbolism by doxygen 1.5.4