/usr/include/givaro/givpoly1addsub.inl is in libgivaro-dev 3.2.13-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | // ==========================================================================
// $Source: /var/lib/cvs/Givaro/src/library/poly1/givpoly1addsub.inl,v $
// Copyright(c)'94-97 by Givaro Team
// see the copyright file.
// Authors: T. Gautier
// $Id: givpoly1addsub.inl,v 1.2 2008-04-22 15:57:14 jgdumas Exp $
// ==========================================================================
#ifndef __GIV__POLY__ADDSUB__inl__
#define __GIV__POLY__ADDSUB__inl__
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::addin (Rep& R, const Rep& P) const
{
// this->write(this->write(std::cout, R) << " += ", P) << std::endl;
size_t i;
size_t sP = P.size();
size_t sR = R.size();
if (sP == 0) return R;
if (sR == 0) { return assign(R,P); }
// if (sR == 0) { R.copy(P); return R; }
// if (sR == sP){ _supportdomain.addin(R,P); return; }
if (sR < sP) {
Rep tmp; tmp.copy(P);
for (i=0; i<sR; ++i) _domain.addin(tmp[i], R[i]);
R.logcopy(tmp);
}
else {
for (i=0; i<sP; ++i) _domain.addin(R[i], P[i]);
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::add(Rep& R, const Rep& P, const Rep& Q) const
{
size_t sP = P.size();
size_t sQ = Q.size();
size_t sR = R.size();
if (sP == 0) { R.copy(Q); return R; }
if (sQ == 0) { R.copy(P); return R; }
// JGD 04.11.1999
// if (sP == sQ) {
// R.reallocate(sP);
// _supportdomain.add(R,P,Q);
// return;
// }
size_t i, max = sP < sQ ? sQ : sP;
if (sR != max) R.reallocate(max);
if (sP < sQ)
{
for (i=0; i<sP; ++i) _domain.add(R[i], P[i], Q[i]);
// for (; i<sQ; ++i) _domain.assign(R[i], Q[i]);
// JGD 05.11.1999
for (; i<sQ; ++i) R[i] = Q[i];
}
else {
for (i=0; i<sQ; ++i) _domain.add(R[i], P[i], Q[i]);
// for (; i<sP; ++i) _domain.assign(R[i], P[i]);
// JGD 05.11.1999
for (; i<sP; ++i) R[i] = P[i];
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::add
(Rep& R, const Rep& P, const Type_t& val) const
{
size_t sP = P.size();
if (sP == 0) {
R.reallocate(1);
_domain.assign(R[0],val);
}
else {
assign(R, P);
_domain.add(R[0],P[0],val);
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::add
(Rep& R, const Type_t& val, const Rep& P) const
{
size_t sP = P.size();
if (sP == 0) {
R.reallocate(1);
_domain.assign(R[0],val);
}
else {
assign(R, P);
_domain.add(R[0],val, P[0]);
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::subin (Rep& R, const Rep& P) const
{
size_t sP = P.size();
size_t sR = R.size();
if (sP == 0) return R;
if (sR == 0) { return neg(R,P); }
// if (sR == sP){ _supportdomain.subin(R,P); return; }
if (sR < sP) {
size_t i;
Rep tmp; tmp.reallocate(sP);
for (i=0; i<sR; ++i) _domain.sub(tmp[i], R[i], P[i]);
for (; i<sP; ++i) _domain.neg(tmp[i], P[i]);
R.logcopy(tmp);
}
else {
for (size_t i=0; i<sP; ++i) _domain.subin(R[i], P[i]);
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::sub(Rep& R, const Rep& P, const Rep& Q) const
{
size_t sP = P.size();
size_t sQ = Q.size();
size_t sR = R.size();
if (sQ == 0) { R.copy(P); return R; }
if (sP == 0) { return neg(R,Q); }
// if (sP == sQ) {
// R.reallocate(sP);
// _supportdomain.sub(R,P,Q);
// return;
// }
size_t i, max = sP < sQ ? sQ : sP;
if (sR != max) R.reallocate(max);
if (sP < sQ)
{
for (i=0; i<sP; ++i) _domain.sub(R[i], P[i], Q[i]);
for (; i<sQ; ++i) _domain.neg(R[i], Q[i]);
}
else {
for (i=0; i<sQ; ++i) _domain.sub(R[i], P[i], Q[i]);
for (; i<sP; ++i) _domain.assign(R[i], P[i]);
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::sub
(Rep& R, const Rep& P, const Type_t& val) const
{
size_t sP = P.size();
if (sP == 0) {
R.reallocate(1);
_domain.neg(R[0],val);
}
else {
assign(R, P);
_domain.sub(R[0],P[0],val);
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::sub
(Rep& R, const Type_t& val, const Rep& P) const
{
size_t sP = P.size();
if (sP == 0) {
R.reallocate(1);
_domain.neg(R[0],val);
}
else {
neg(R, P);
_domain.add(R[0],val, P[0]);
}
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::negin (Rep& R ) const
{
// _supportdomain.negin(R);
size_t sR = R.size();
if (sR == 0) { return R; }
for (size_t i=0; i<sR; ++i) _domain.negin(R[i]);
return R;
}
template <class Domain>
inline typename Poly1Dom<Domain,Dense>::Rep& Poly1Dom<Domain,Dense>::neg (Rep& R, const Rep& P ) const
{
// _supportdomain.neg(R,P);
size_t sP = P.size();
R.reallocate(sP);
if (sP == 0) { return R; }
for (size_t i=0; i<sP; ++i) _domain.neg(R[i],P[i]);
return R;
}
#endif
|