source: git/Singular/intvec.h @ 5480da

spielwiese
Last change on this file since 5480da was 6d3ffec, checked in by Hans Schönemann <hannes@…>, 27 years ago
* hannes: added Makefile to "touch -r mod2.h ...." git-svn-id: file:///usr/local/Singular/svn/trunk@217 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.2 KB
Line 
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
14class 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};
73intvec * ivCopy(intvec * o);
74intvec * ivAdd(intvec * a, intvec * b);
75intvec * ivSub(intvec * a, intvec * b);
76intvec * ivTranp(intvec * o);
77int      ivTrace(intvec * o);
78intvec * ivMult(intvec * a, intvec * b);
79void     ivTriangMat(intvec * imat, int srw, int col);
80int      ivFirstEmptyRow(intvec * imat);
81void     ivCancelContent(intvec * imat,int from=1);
82intvec * ivSolveIntMat(intvec * imat);
83
84#endif
Note: See TracBrowser for help on using the repository browser.