Ejemplo n.º 1
0
// Solve the equations
void AlgRemez::equations(void) {
  char *fname = "equations()";
//   VRB.Func(cname,fname);
  bigfloat x, y, z;
  int i, j, ip;
  bigfloat *aa;

  bigfloat *AA = new bigfloat[(neq)*(neq)];
  if(AA == 0) ERR.Pointer(cname,fname,"AA");
  VRB.Smalloc(cname,fname,"AA",AA,(neq)*(neq)* sizeof(bigfloat));
  bigfloat *BB = new bigfloat[neq];
  if(BB == 0) ERR.Pointer(cname,fname,"BB");
  VRB.Smalloc(cname,fname,"BB",BB,(neq) * sizeof(bigfloat));
  
  for (i = 0; i < neq; i++) {	// set up the equations for solution by simq()
    ip = neq * i;		// offset to 1st element of this row of matrix
    x = xx[i];			// the guess for this row
    y = func(x);		// right-hand-side vector

    z = (bigfloat)1l;
    aa = AA+ip;
    for (j = 0; j <= n; j++) {
      *aa++ = z;
      z *= x;
    }

    z = (bigfloat)1l;
    for (j = 0; j < d; j++) {
      *aa++ = -y * z;
      z *= x;
    }
    BB[i] = y * z;		// Right hand side vector
  }

  // Solve the simultaneous linear equations.
  if (simq(AA, BB, param, neq)) ERR.General(cname,fname,"simq failed\n");;

  VRB.Sfree(cname,fname, "AA",AA);
  delete [] AA;
  VRB.Sfree(cname,fname, "BB",BB);
  delete [] BB;

}
Ejemplo n.º 2
0
// Solve the equations
void AlgRemez::equations(void) {
  bigfloat x, y, z;
  int i, j, ip;
  bigfloat *aa;

  bigfloat *AA = new bigfloat[(neq)*(neq)];
  bigfloat *BB = new bigfloat[neq];
  
  for (i = 0; i < neq; i++) {	// set up the equations for solution by simq()
    ip = neq * i;		// offset to 1st element of this row of matrix
    x = xx[i];			// the guess for this row
    y = func(x);		// right-hand-side vector

    z = (bigfloat)1l;
    aa = AA+ip;
    for (j = 0; j <= n; j++) {
      *aa++ = z;
      z *= x;
    }

    z = (bigfloat)1l;
    for (j = 0; j < d; j++) {
      *aa++ = -y * z;
      z *= x;
    }
    BB[i] = y * z;		// Right hand side vector
  }

  // Solve the simultaneous linear equations.
  if (simq(AA, BB, param, neq)) {
    printf("simq failed\n");
    exit(0);
  }

  delete [] AA;
  delete [] BB;

}