def central_diff_weights(Np, ndiv=<NUM_LIT:1>):
if Np < ndiv + <NUM_LIT:1>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>if Np % <NUM_LIT:2> == <NUM_LIT:0>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>from scipy import linalg<EOL>ho = Np >> <NUM_LIT:1><EOL>x = arange(-ho,ho+<NUM_LIT:1.0>)<EOL>x = x[:,newaxis]<EOL>X = x**<NUM_LIT:0.0><EOL>for k in range(<NUM_LIT:1>,Np):<EOL><INDENT>X = hstack([X,x**k])<EOL><DEDENT>w = product(arange(<NUM_LIT:1>,ndiv+<NUM_LIT:1>),axis=<NUM_LIT:0>)*linalg.inv(X)[ndiv]<EOL>return w<EOL>
Return weights for an Np-point central derivative.

Assumes equally-spaced function points.

If weights are in the vector w, then
derivative is w[0] * f(x-ho*dx) + ... + w[-1] * f(x+h0*dx)

Parameters
----------
Np : int
    Number of points for the central derivative.
ndiv : int, optional
    Number of divisions.  Default is 1.

Notes
-----
Can be inaccurate for large number of points.