| 123 | } |
| 124 | |
| 125 | void sub(Ring_Element& ans,const Ring_Element& a,const Ring_Element& b) |
| 126 | { |
| 127 | assert(a.FFTD); |
| 128 | if (a.rep!=b.rep) { throw rep_mismatch(); } |
| 129 | if (a.FFTD!=b.FFTD) { throw pr_mismatch(); } |
| 130 | if (a.element.empty()) |
| 131 | { |
| 132 | ans = b; |
| 133 | ans.negate(); |
| 134 | return; |
| 135 | } |
| 136 | else if (b.element.empty()) |
| 137 | { |
| 138 | ans = a; |
| 139 | return; |
| 140 | } |
| 141 | |
| 142 | if (&ans == &a) |
| 143 | { |
| 144 | ans -= b; |
| 145 | return; |
| 146 | } |
| 147 | else if (&ans == &b) |
| 148 | { |
| 149 | ans.negate(); |
| 150 | ans += a; |
| 151 | return; |
| 152 | } |
| 153 | |
| 154 | ans.prepare(a); |
| 155 | for (int i=0; i<(*ans.FFTD).phi_m(); i++) |
| 156 | ans.element.push_back(a.element[i].sub(b.element[i], a.FFTD->get_prD())); |
| 157 | } |
| 158 | |
| 159 | |
| 160 |
nothing calls this directly
no test coverage detected