Functions
int64vec.cc File Reference
#include <misc/auxiliary.h>
#include <misc/int64vec.h>
#include <misc/intvec.h>
#include <omalloc/omalloc.h>

Go to the source code of this file.

Functions

int64veciv64Add (int64vec *a, int64vec *b)
 
int64veciv64Sub (int64vec *a, int64vec *b)
 

Function Documentation

◆ iv64Add()

int64vec* iv64Add ( int64vec a,
int64vec b 
)

Definition at line 173 of file int64vec.cc.

174 {
175  int64vec * iv;
176  int64 mn, ma, i;
177  if (a->cols() != b->cols()) return NULL;
178  mn = si_min(a->rows(),b->rows());
179  ma = si_max(a->rows(),b->rows());
180  if (a->cols() == 1)
181  {
182  iv = new int64vec(ma);
183  for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] + (*b)[i];
184  if (ma > mn)
185  {
186  if (ma == a->rows())
187  {
188  for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
189  }
190  else
191  {
192  for(i=mn; i<ma; i++) (*iv)[i] = (*b)[i];
193  }
194  }
195  return iv;
196  }
197  if (mn != ma) return NULL;
198  iv = new int64vec(a);
199  for (i=0; i<mn*a->cols(); i++) { (*iv)[i] += (*b)[i]; }
200  return iv;
201 }
const poly a
Definition: syzextra.cc:212
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
long int64
Definition: auxiliary.h:66
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ iv64Sub()

int64vec* iv64Sub ( int64vec a,
int64vec b 
)

Definition at line 203 of file int64vec.cc.

204 {
205  int64vec * iv;
206  int mn, ma,i;
207  if (a->cols() != b->cols()) return NULL;
208  mn = si_min(a->rows(),b->rows());
209  ma = si_max(a->rows(),b->rows());
210  if (a->cols() == 1)
211  {
212  iv = new int64vec(ma);
213  for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] - (*b)[i];
214  if (ma > mn)
215  {
216  if (ma == a->rows())
217  {
218  for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
219  }
220  else
221  {
222  for(i=mn; i<ma; i++) (*iv)[i] = -(*b)[i];
223  }
224  }
225  return iv;
226  }
227  if (mn != ma) return NULL;
228  iv = new int64vec(a);
229  for (i=0; i<mn*a->cols(); i++) { (*iv)[i] -= (*b)[i]; }
230  return iv;
231 }
const poly a
Definition: syzextra.cc:212
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213