source: git/Singular/intvec.h @ 4b2155

spielwiese
Last change on this file since 4b2155 was 4b2155, checked in by Olaf Bachmann <obachman@…>, 25 years ago
*string() implemented for all types -- no line breaks *inmtat(intvec, n, m) implemented git-svn-id: file:///usr/local/Singular/svn/trunk@2986 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.7 1999-04-16 07:53:34 obachman 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          Werror("wrong intvec 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(int dim = 2);
58    char * ivString(int mat=0,int spaces=0, int dim=2);
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            v=NULL;
68         }
69       }
70};
71intvec * ivCopy(intvec * o);
72intvec * ivAdd(intvec * a, intvec * b);
73intvec * ivSub(intvec * a, intvec * b);
74intvec * ivTranp(intvec * o);
75int      ivTrace(intvec * o);
76intvec * ivMult(intvec * a, intvec * b);
77void     ivTriangMat(intvec * imat, int srw, int col);
78int      ivFirstEmptyRow(intvec * imat);
79void     ivCancelContent(intvec * imat,int from=1);
80intvec * ivSolveIntMat(intvec * imat);
81
82#endif
Note: See TracBrowser for help on using the repository browser.