title: Problems with GSL using Legendre polynomials
body: <p>I'm trying to update an old code that was using a version of GSL with deprecated functions, but I'm having troubles to find how to use the new version of the normalized Legendre polynomials functions. Here's a snippet that summarizes the problem:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;gsl/gsl_sf_legendre.h&gt;
  #include &lt;cmath&gt;
  
  #define GSL_NEW
  
  using namespace std;
  
  int main() {
  
    int order = 17;
    int ntheta = 36;
    double theta_step = M_PI / ntheta;
    double c, theta;
    double legendre[ntheta][order+1];
  
    for( int m = 0; m &lt;= order; m += 2) {
      for(int l = m; l &lt;= ntheta; l += 2 ) {
        for( int t = 0; t &lt; ntheta; t++ ) {
          theta = ( ntheta + 0.5 ) * theta_step;
          c = cos(theta);
  
          if( l == m ) {
  #ifdef GSL_NEW
            gsl_sf_legendre_array( GSL_SF_LEGENDRE_SPHARM, order, c, &amp;legendre[t][l] );
            cout &lt;&lt; legendre[t][l] &lt;&lt; endl;
  #else
            gsl_sf_legendre_sphPlm_array(order, m, c, &amp;legendre[t][l] );
            cout &lt;&lt; legendre[t][l] &lt;&lt; endl;
  #endif
          }
        }
      }
    }
  }
  </code></pre>
  
  <p>When I compile using GSL 1.9 I use the deprecated function <code>gsl_sf_legendre_sphPlm_array</code>, while when I compute with GSL 2.5 I use the new function <code>gsl_sf_legendre_array</code> which explicitely requires a keyword for the normalization (<code>GSL_SF_LEGENDRE_SPHARM</code>) and doesn't ask for the parameter <code>m</code>. The old version gives me consistent results, while the new one returns me a segmentation fault after 25 t loops. Can anybody of you help me correct the code and explain me what I'm doing wrong?</p>