Ramón Casero Cañas on Mon, 13 Jan 2003 13:08:46 +0100 (MET)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

is this the right list for this question?


I do not know whether this is the right list for a question regarding some
C++ code I'm writting based on PARI functions (maybe I should write to the
users list). It's basic code, actually; at present, just input a (bool **) and
copy it to a PARI matrix. I get a segmentation fault at the outbeaut()
function:

----------------------------------------------------------------

inverse_mat_mod2: size = 32
Matrix? a = 1078694052

[  ***   segmentation fault: bug in PARI or calling program.
  ***   Error in the PARI system. End of program.

----------------------------------------------------------------

bool inverse_mat_mod2(bool **_a, unsigned _size, bool _CHECK) {
  long paristacksize = 500000;
  GEN a;           // temp matrix by columns
  unsigned i, j;   // counter
  unsigned sizepari = _size + 1;
  GEN v;           // auxiliay pointer for columns
  GEN z;           // auxiliary element of the matrix

  if (sizeof(long) * _size * _size > (unsigned)paristacksize) {
    paristacksize = sizeof(long) * _size * _size * 2; // this's a guess of
mine w/o any base
  }
  pari_init(paristacksize, 2); // init PARI stack

  /* allocate memory for the temp matrix
   * note: remember that PARI matrices of mxn need (m+1)x(n+1), and
   * that elements go a[1], a[2], ..., as a[0] is for type
   * information */
  std::cout << "inverse_mat_mod2: size = " << _size << std::endl;
  a = cgetg(sizepari, t_MAT); // `a' has _size columns
  if (!a) err(talker, "inverse_mat_mod2: memory!\n");
  for (i = 1; i < sizepari; ++i) { // alloc `a' columns
    a[i] = lgetg(sizepari, t_COL);
    if (!a[i]) err(talker, "inverse_mat_mod2: memory!\n");
  }
  for (i = 1; i < sizepari; ++i) { // alloc space for elements
    for (j = 1; j < sizepari; ++j) {

       z = gcoeff(a, i, j);
       z = cgetg(3, t_INTMOD);
       z[1] = (long)2;
       z[2] = (long)1;

    }
  }

  std::cout << "Matrix? a = " << (int)a << std::endl;
  outbeaut(a);
  return true;
}

-- 
+++ GMX - Mail, Messaging & more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!