c_cli_gjpq.c
Go to the documentation of this file.
1 // BEGIN_HEADER
2 // -----------------------------------------------------------------------------
3 // Gauss-Jacobi Quadrature Implementation
4 // Authors: Rohit Goswami <rgoswami[at]ieee.org>
5 // Source: GaussJacobiQuad Library
6 // License: MIT
7 // GitHub Repository: https://github.com/HaoZeke/GaussJacobiQuad
8 // Date: 2023-08-28
9 // Commit: c442f77
10 // -----------------------------------------------------------------------------
11 // This code is part of the GaussJacobiQuad library, providing an efficient
12 // implementation for Gauss-Jacobi quadrature nodes and weights computation.
13 // -----------------------------------------------------------------------------
14 // To cite this software:
15 // Rohit Goswami (2023). HaoZeke/GaussJacobiQuad: v0.1.0.
16 // Zenodo: https://doi.org/10.5281/ZENODO.8285112
17 // ---------------------------------------------------------------------
18 // END_HEADER
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include "GaussJacobiQuadCInterp.h"
23 
24 int main(int argc, char *argv[]) {
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)
int main(int argc, char *argv[])
Definition: c_cli_gjpq.c:24