c_cli_gjpq.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "GaussJacobiQuadCInterp.h"
+ Include dependency graph for c_cli_gjpq.c:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 24 of file c_cli_gjpq.c.

24  {
25  if (argc != 5) {
26  fprintf(stderr, "Usage: %s <n_points> <alpha> <beta> <method>\n", argv[0]);
27  fprintf(stderr, " n_points: Number of quadrature points (integer)\n");
28  fprintf(stderr, " alpha: Parameter alpha for Gauss-Jacobi quadrature (must be > -1)\n");
29  fprintf(stderr, " beta: Parameter beta for Gauss-Jacobi quadrature (must be > -1)\n");
30  fprintf(stderr, " method: Method to use for computation (supported: 'rec', 'gw', 'algo665')\n");
31  return EXIT_FAILURE;
32  }
33 
34  int n_points = atoi(argv[1]);
35  double alpha = atof(argv[2]);
36  double beta = atof(argv[3]);
37  const char *method = argv[4];
38 
39  double *x = (double*) malloc((size_t) n_points * sizeof(double));
40  double *wts = (double*) malloc((size_t) n_points * sizeof(double));
41 
42  gauss_jacobi_c(&n_points, &alpha, &beta, x, wts, method);
43 
44  for (int i = 0; i < n_points; ++i) {
45  printf("Root: %e, Weight: %e\n", x[i], wts[i]);
46  }
47 
48  free(x);
49  free(wts);
50 
51  return EXIT_SUCCESS;
52 }
void gauss_jacobi_c(int *npts, double *alpha, double *beta, double x[], double wts[], const char *method)