source: git/kernel/intvec.h @ 30b8381

spielwiese
Last change on this file since 30b8381 was 30b8381, checked in by Hans Schönemann <hannes@…>, 20 years ago
*hannes: betti and weights (from 2-0-5) git-svn-id: file:///usr/local/Singular/svn/trunk@7267 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.5 KB
Line 
1#ifndef INTVEC_H
2#define INTVEC_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id: intvec.h,v 1.2 2004-07-16 08:43:00 Singular Exp $ */
7/*
8* ABSTRACT: class intvec: lists/vectors of integers
9*/
10#include <string.h>
11#include "omalloc.h"
12#include "febase.h"
13
14class intvec
15{
16private:
17  int *v;
18  int row;
19  int col;
20public:
21
22  inline intvec(int l = 1)
23    {
24      v = (int *)omAlloc0(sizeof(int)*l);
25      row = l;
26      col = 1;
27    }
28  intvec(int s, int e);
29  intvec(int r, int c, int init);
30  intvec(intvec* iv);
31
32  void resize(int new_length);
33  inline int range(int i)
34    { return ((i<row) && (i>=0) && (col==1)); }
35  inline int range(int i, int j)
36    { return ((i<row) && (i>=0) && (j<col) && (j>=0)); }
37  inline int& operator[](int i)
38    {
39#ifndef NDEBUG
40      if((i<0)||(i>=row*col))
41      {
42        Werror("wrong intvec index:%d\n",i);
43      }
44#endif
45      return v[i];
46    }
47#define IMATELEM(M,I,J) (M)[(I-1)*(M).cols()+J-1]
48  void operator+=(int intop);
49  void operator-=(int intop);
50  void operator*=(int intop);
51  void operator/=(int intop);
52  void operator%=(int intop);
53  // -2: not compatible, -1: <, 0:=, 1: >
54  int compare(intvec* o);
55  int compare(int o);
56  inline int  length() const { return col*row; }
57  inline int  cols() const { return col; }
58  inline int  rows() const { return row; }
59  inline void length(int l) { row = l; col = 1; }
60  void show(int mat=0,int spaces=0);
61  inline void makeVector() { row*=col;col=1; }
62  char * String(int dim = 2);
63  char * ivString(int mat=0,int spaces=0, int dim=2);
64  inline ~intvec()
65    {
66      if (v!=NULL)
67      {
68        omFreeSize((ADDRESS)v,sizeof(int)*row*col);
69        v=NULL;
70      }
71    }
72  inline void ivTEST()
73    {
74      omCheckAddrSize((ADDRESS)v,sizeof(int)*row*col);
75    }
76  inline int min_in()
77  {
78    int m=v[0];
79    for (int i=row*col; i>0; i--) if (v[i]<m) m=v[i];
80    return m;
81  }
82  // keiner (ausser obachman) darf das folgenden benutzen !!!
83  inline int * ivGetVec() { return v; }
84};
85intvec * ivCopy(intvec * o);
86intvec * ivAdd(intvec * a, intvec * b);
87intvec * ivSub(intvec * a, intvec * b);
88intvec * ivTranp(intvec * o);
89int      ivTrace(intvec * o);
90intvec * ivMult(intvec * a, intvec * b);
91//void     ivTriangMat(intvec * imat);
92void     ivTriangIntern(intvec * imat, int &ready, int &all);
93intvec * ivSolveKern(intvec * imat, int ready);
94
95
96#ifdef MDEBUG
97#define ivTest(v) v->ivTEST()
98#else
99#define ivTest(v)   ((void)0)
100#endif
101#undef INLINE_THIS
102
103#endif
Note: See TracBrowser for help on using the repository browser.