1 | #ifndef INTVEC_H |
---|
2 | #define INTVEC_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id: intvec.h,v 1.4 1997-04-30 15:25:29 Singular Exp $ */ |
---|
7 | /* |
---|
8 | * ABSTRACT: class intvec: lists/vectors of integers |
---|
9 | */ |
---|
10 | #include <string.h> |
---|
11 | #include "mmemory.h" |
---|
12 | #include "febase.h" |
---|
13 | |
---|
14 | class intvec |
---|
15 | { |
---|
16 | private: |
---|
17 | int *v; |
---|
18 | int row; |
---|
19 | int col; |
---|
20 | public: |
---|
21 | intvec(int l=1) |
---|
22 | { |
---|
23 | v = (int *)Alloc0(sizeof(int)*l); |
---|
24 | row = l; |
---|
25 | col = 1; |
---|
26 | } |
---|
27 | intvec(int s, int e); |
---|
28 | intvec(int r, int c, int init); |
---|
29 | intvec(intvec* iv); |
---|
30 | int range(int i) |
---|
31 | { return ((i<row) && (i>=0) && (col==1)); } |
---|
32 | int range(int i, int j) |
---|
33 | { return ((i<row) && (i>=0) && (j<col) && (j>=0)); } |
---|
34 | int& operator[](int i) { |
---|
35 | if((i<0)||(i>=row*col)) |
---|
36 | { |
---|
37 | Print("wrong index:%d\n",i); |
---|
38 | } |
---|
39 | return v[i];} |
---|
40 | #define IMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1] |
---|
41 | void operator+=(int intop); |
---|
42 | void operator-=(int intop); |
---|
43 | void operator*=(int intop); |
---|
44 | void operator/=(int intop); |
---|
45 | void operator%=(int intop); |
---|
46 | // -2: not compatible, -1: <, 0:=, 1: > |
---|
47 | int compare(intvec* o); |
---|
48 | int compare(int o); |
---|
49 | int length() const { return col*row; } |
---|
50 | int cols() const { return col; } |
---|
51 | int rows() const { return row; } |
---|
52 | void length(int l) { row = l; col = 1; } |
---|
53 | void show(int mat=0,int spaces=0); |
---|
54 | void makeVector() { row*=col;col=1; } |
---|
55 | // keiner (ausser obachman) darf das folgenden benutzen !!! |
---|
56 | int * ivGetVec() { return v; } |
---|
57 | char * String(); |
---|
58 | char * ivString(int mat=0,int spaces=0); |
---|
59 | ~intvec() |
---|
60 | { |
---|
61 | #ifdef MDEBUG |
---|
62 | mmTestL(this); |
---|
63 | #endif |
---|
64 | if (v!=NULL) |
---|
65 | { |
---|
66 | Free((ADDRESS)v,sizeof(int)*row*col); |
---|
67 | #ifdef TEST |
---|
68 | v=NULL; |
---|
69 | #endif |
---|
70 | } |
---|
71 | } |
---|
72 | }; |
---|
73 | intvec * ivCopy(intvec * o); |
---|
74 | intvec * ivAdd(intvec * a, intvec * b); |
---|
75 | intvec * ivSub(intvec * a, intvec * b); |
---|
76 | intvec * ivTranp(intvec * o); |
---|
77 | int ivTrace(intvec * o); |
---|
78 | intvec * ivMult(intvec * a, intvec * b); |
---|
79 | void ivTriangMat(intvec * imat, int srw, int col); |
---|
80 | int ivFirstEmptyRow(intvec * imat); |
---|
81 | void ivCancelContent(intvec * imat,int from=1); |
---|
82 | intvec * ivSolveIntMat(intvec * imat); |
---|
83 | |
---|
84 | #endif |
---|