Changeset eea50a in git for libpolys/coeffs/bigintmat.cc
- Timestamp:
- Jun 20, 2012, 12:28:22 PM (12 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- afda228e98d9cb285f30c2bb20125b83462b7ecd
- Parents:
- 91c8a9344b090c87f8af8b4f8f02bfca00510479
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/bigintmat.cc
r91c8a9 reea50a 24 24 for (int j=1; j<=col; j++) 25 25 { 26 t->set(j, i, v[(i-1)*col+(j-1)]);26 t->set(j, i, BIMATELEM(*this,i,j)); 27 27 } 28 28 } … … 115 115 { 116 116 if (a->cols() != b->cols()) return NULL; 117 if (a->rows() != b->rows()) return NULL; 117 118 if (a->basecoeffs() != b->basecoeffs()) { return NULL; } 118 119 119 const int mn = si_min(a->rows(),b->rows());120 const int ma = si_max(a->rows(),b->rows());121 122 120 const coeffs basecoeffs = a->basecoeffs(); 123 121 124 122 int i; 125 123 126 if (a->cols() == 1) 127 { 128 bigintmat * bim = new bigintmat(ma, 1, basecoeffs); 129 130 for (i=0; i<mn; i++) 131 bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs); 132 133 if (ma > mn) 134 { 135 if (ma == a->rows()) 136 for(i=mn; i<ma; i++) 137 bim->set(i, (*a)[i], basecoeffs); 138 else 139 for(i=mn; i<ma; i++) 140 bim->set(i, (*b)[i], basecoeffs); 141 } 142 return bim; 143 } 144 145 if (mn != ma) return NULL; 146 147 bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs); 148 149 for (i=0; i<mn*a->cols(); i++) 124 bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs); 125 126 for (i=a->rows()*a->cols()-1;i>=0; i--) 150 127 bim->rawset(i, n_Add((*a)[i], (*b)[i], basecoeffs), basecoeffs); 151 128 … … 174 151 { 175 152 if (a->cols() != b->cols()) return NULL; 153 if (a->rows() != b->rows()) return NULL; 176 154 if (a->basecoeffs() != b->basecoeffs()) { return NULL; } 177 155 178 const int mn = si_min(a->rows(),b->rows());179 const int ma = si_max(a->rows(),b->rows());180 181 156 const coeffs basecoeffs = a->basecoeffs(); 182 157 183 158 int i; 184 159 185 if (a->cols() == 1) 186 { 187 bigintmat * bim = new bigintmat(ma, 1, basecoeffs); 188 189 for (i=0; i<mn; i++) 190 bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs); 191 192 if (ma > mn) 193 { 194 if (ma == a->rows()) 195 { 196 for(i=mn; i<ma; i++) 197 bim->set(i, (*a)[i], basecoeffs); 198 } 199 else 200 for(i=mn; i<ma; i++) 201 { 202 number n = b->get(i); 203 n = n_Neg(n, basecoeffs); 204 bim->rawset(i, n, basecoeffs); 205 } 206 } 207 return bim; 208 } 209 210 if (mn != ma) return NULL; 211 212 bigintmat * bim = new bigintmat(mn, a->cols(), basecoeffs); 213 214 for (i=0; i<mn*a->cols(); i++) 160 bigintmat * bim = new bigintmat(a->rows(), a->cols(), basecoeffs); 161 162 for (i=a->rows()*a->cols()-1;i>=0; i--) 215 163 bim->rawset(i, n_Sub((*a)[i], (*b)[i], basecoeffs), basecoeffs); 216 164
Note: See TracChangeset
for help on using the changeset viewer.