Changeset c232af in git for Singular/intvec.cc
- Timestamp:
- Aug 14, 2000, 2:58:28 PM (24 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'c5facdfddea2addfd91babd8b9019161dea4b695')
- Children:
- d26c2e9dd38f1531c0e77c38e6177109182b5bca
- Parents:
- 4697a8a1ccbf49d0048033ea29c651e3966ba729
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/intvec.cc
r4697a8a rc232af 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: intvec.cc,v 1.1 6 1999-11-15 17:20:07obachman Exp $ */4 /* $Id: intvec.cc,v 1.17 2000-08-14 12:56:21 obachman Exp $ */ 5 5 /* 6 6 * ABSTRACT: class intvec: lists/vectors of integers … … 12 12 #include "febase.h" 13 13 #include "intvec.h" 14 #include "mmemory.h"14 #include <omalloc.h> 15 15 16 16 /*0 implementation*/ 17 17 18 #ifdef MDEBUG 19 intvec::intvec(char* file, int line, int l) 20 { 21 v = (int *)mmDBAllocBlock0(sizeof(int)*l, file, line); 22 row = l; 23 col = 1; 24 } 25 26 intvec::intvec(char* file, int line, intvec* iv) 18 19 intvec::intvec(intvec* iv) 27 20 { 28 21 row = iv->rows(); 29 22 col = iv->cols(); 30 v = (int *) mmDBAllocBlock(sizeof(int)*row*col, file, line);23 v = (int *)omAlloc(sizeof(int)*row*col); 31 24 for (int i=0; i<row*col; i++) 32 25 { … … 35 28 } 36 29 37 intvec::intvec( char* file, int line,int s, int e)30 intvec::intvec(int s, int e) 38 31 { 39 32 int inc; … … 49 42 inc = -1; 50 43 } 51 v = (int *) mmDBAllocBlock(sizeof(int)*row, file, line);44 v = (int *)omAlloc(sizeof(int)*row); 52 45 for (int i=0; i<row; i++) 53 46 { … … 57 50 } 58 51 59 intvec::intvec( char* file, int line,int r, int c, int init)52 intvec::intvec(int r, int c, int init) 60 53 { 61 54 row = r; … … 63 56 int l = r*c; 64 57 if ((r>0) && (c>0)) 65 v = (int *)mmDBAllocBlock(sizeof(int)*l, file, line); 66 else 67 v = NULL; 68 for (int i=0; i<l; i++) 69 { 70 v[i] = init; 71 } 72 } 73 74 #endif // ! MDEBUG 75 76 77 intvec::intvec(intvec* iv) 78 { 79 row = iv->rows(); 80 col = iv->cols(); 81 v = (int *)Alloc(sizeof(int)*row*col); 82 for (int i=0; i<row*col; i++) 83 { 84 v[i] = (*iv)[i]; 85 } 86 } 87 88 intvec::intvec(int s, int e) 89 { 90 int inc; 91 col = 1; 92 if (s<e) 93 { 94 row = e-s+1; 95 inc = 1; 96 } 97 else 98 { 99 row = s-e+1; 100 inc = -1; 101 } 102 v = (int *)Alloc(sizeof(int)*row); 103 for (int i=0; i<row; i++) 104 { 105 v[i] = s; 106 s+=inc; 107 } 108 } 109 110 intvec::intvec(int r, int c, int init) 111 { 112 row = r; 113 col = c; 114 int l = r*c; 115 if ((r>0) && (c>0)) 116 v = (int *)Alloc(sizeof(int)*l); 58 v = (int *)omAlloc(sizeof(int)*l); 117 59 else 118 60 v = NULL; … … 169 111 { 170 112 assume(new_length > 0 && col == 1); 171 v = (int*) ReAlloc0(v, row*sizeof(int), new_length*sizeof(int));113 v = (int*) omRealloc0Size(v, row*sizeof(int), new_length*sizeof(int)); 172 114 row = new_length; 173 115 } … … 175 117 char * intvec::String(int dim) 176 118 { 177 return mstrdup(ivString(0, 0, dim));119 return omStrDup(ivString(0, 0, dim)); 178 120 } 179 121 … … 260 202 intvec * ivCopy(intvec * o) 261 203 { 262 intvec * iv= NewIntvecIv(o);204 intvec * iv=new intvec(o); 263 205 return iv; 264 206 } … … 273 215 if (a->cols() == 1) 274 216 { 275 iv = NewIntvec1(ma);217 iv = new intvec(ma); 276 218 for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] + (*b)[i]; 277 219 if (ma > mn) … … 289 231 } 290 232 if (mn != ma) return NULL; 291 iv = NewIntvec1(a);233 iv = new intvec(a); 292 234 for (i=0; i<mn*a->cols(); i++) { (*iv)[i] += (*b)[i]; } 293 235 return iv; … … 303 245 if (a->cols() == 1) 304 246 { 305 iv = NewIntvec1(ma);247 iv = new intvec(ma); 306 248 for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] - (*b)[i]; 307 249 if (ma > mn) … … 319 261 } 320 262 if (mn != ma) return NULL; 321 iv = NewIntvec1(a);263 iv = new intvec(a); 322 264 for (i=0; i<mn*a->cols(); i++) { (*iv)[i] -= (*b)[i]; } 323 265 return iv; … … 327 269 { 328 270 int i, j, r = o->rows(), c = o->cols(); 329 intvec * iv= NewIntvec3(c, r, 0);271 intvec * iv= new intvec(c, r, 0); 330 272 for (i=0; i<r; i++) 331 273 { … … 353 295 intvec * iv; 354 296 if (ca != rb) return NULL; 355 iv = NewIntvec3(ra, cb, 0);297 iv = new intvec(ra, cb, 0); 356 298 for (i=0; i<ra; i++) 357 299 { … … 472 414 static intvec * ivIndepCols(intvec * imat) 473 415 { 474 intvec * result= NewIntvec3(1,imat->cols(),0);416 intvec * result=new intvec(1,imat->cols(),0); 475 417 int i,j; 476 418 … … 489 431 static intvec * ivBasicSol(intvec * imat) 490 432 { 491 intvec * result = NewIntvec3(2*imat->cols(),imat->cols(),0);492 intvec * indep=ivIndepCols(imat),*actsol= NewIntvec1(imat->cols());433 intvec * result = new intvec(2*imat->cols(),imat->cols(),0); 434 intvec * indep=ivIndepCols(imat),*actsol=new intvec(imat->cols()); 493 435 int actPosSol=1,actNegSol=imat->cols()+1,i=imat->cols(),j,k; 494 436 int tgcd,tlcm; … … 552 494 intvec * ivSolveIntMat(intvec * imat) 553 495 { 554 intvec * result= NewIntvec1(imat->cols());496 intvec * result=new intvec(imat->cols()); 555 497 intvec * basesol=ivBasicSol(imat); 556 498 int i=imat->cols(),j,k,l,t;
Note: See TracChangeset
for help on using the changeset viewer.