source: git/Singular/intvec.h @ f6b5f0

spielwiese
Last change on this file since f6b5f0 was f6b5f0, checked in by Hans Schönemann <hannes@…>, 27 years ago
* hannes: change Log: and Header: to Id: git-svn-id: file:///usr/local/Singular/svn/trunk@73 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.1 KB
Line 
1#ifndef INTVEC_H
2#define INTVEC_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/*
7* ABSTRACT
8*/
9#include <string.h>
10#include "mmemory.h"
11#include "febase.h"
12
13class intvec
14{
15  private:
16    int *v;
17    int row;
18    int col;
19  public:
20    intvec(int l=1)
21    {
22      v = (int *)Alloc0(sizeof(int)*l);
23      row = l;
24      col = 1;
25    }
26    intvec(int s, int e);
27    intvec(int r, int c, int init);
28    intvec(intvec* iv);
29    int range(int i)
30       { return ((i<row) && (i>=0) && (col==1)); }
31    int range(int i, int j)
32       { return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
33    int& operator[](int i) {
34       if((i<0)||(i>=row*col))
35       {
36          Print("wrong index:%d\n",i);
37       }
38       return v[i];}
39#define IMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
40    void operator+=(int intop);
41    void operator-=(int intop);
42    void operator*=(int intop);
43    void operator/=(int intop);
44    void operator%=(int intop);
45    // -2: not compatible, -1: <, 0:=, 1: >
46    int compare(intvec* o);
47    int compare(int o);
48    int  length() const { return col*row; }
49    int  cols() const { return col; }
50    int  rows() const { return row; }
51    void length(int l) { row = l; col = 1; }
52    void show(int spaces=0);
53    void makeVector() { row*=col;col=1; }
54    // keiner (ausser obachman) darf das folgenden benutzen !!!
55    int * ivGetVec() { return v; }
56    char * String();
57    char * ivString();
58    ~intvec()
59       {
60#ifdef MDEBUG
61         mmTestL(this);
62#endif
63         if (v!=NULL)
64         {
65            Free((ADDRESS)v,sizeof(int)*row*col);
66#ifdef TEST
67            v=NULL;
68#endif
69         }
70       }
71};
72intvec * ivCopy(intvec * o);
73intvec * ivAdd(intvec * a, intvec * b);
74intvec * ivSub(intvec * a, intvec * b);
75intvec * ivTranp(intvec * o);
76int      ivTrace(intvec * o);
77intvec * ivMult(intvec * a, intvec * b);
78void     ivTriangMat(intvec * imat, int srw, int col);
79int      ivFirstEmptyRow(intvec * imat);
80void     ivCancelContent(intvec * imat,int from=1);
81intvec * ivSolveIntMat(intvec * imat);
82
83#endif
Note: See TracBrowser for help on using the repository browser.