summaryrefslogtreecommitdiff
path: root/doc/source/user
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-11-04 10:59:29 -0600
committerCharles Harris <charlesr.harris@gmail.com>2016-11-04 18:05:31 -0600
commit93c098a582d1f562a9601c89ac30bb978ccb2eed (patch)
tree59e7adb466f65bdbd4aa6bd93c6be19175f09431 /doc/source/user
parent105592f9c7e94c9f65ccb8d130e58b40686e18d1 (diff)
downloadnumpy-93c098a582d1f562a9601c89ac30bb978ccb2eed.tar.gz
DOC: Fix code example in c-info.python-as-glue.rst.
Corrections to #8023. - Fix index types to ssize_t. - Clean up C code style. Closes #7701. [ci skip]
Diffstat (limited to 'doc/source/user')
-rw-r--r--doc/source/user/c-info.python-as-glue.rst37
1 files changed, 21 insertions, 16 deletions
diff --git a/doc/source/user/c-info.python-as-glue.rst b/doc/source/user/c-info.python-as-glue.rst
index cc360e966..84248def1 100644
--- a/doc/source/user/c-info.python-as-glue.rst
+++ b/doc/source/user/c-info.python-as-glue.rst
@@ -902,27 +902,32 @@ The ``code.c`` file also contains the function ``dfilter2d``:
.. code-block:: c
- /* Assumes b is contiguous and
- a has strides that are multiples of sizeof(double)
- */
+ /*
+ * Assumes b is contiguous and has strides that are multiples of
+ * sizeof(double)
+ */
void
- dfilter2d(double *a, double *b, int *astrides, int *dims)
+ dfilter2d(double *a, double *b, ssize_t *astrides, ssize_t *dims)
{
- int i, j, M, N, S0, S1;
- int r, c, rm1, rp1, cp1, cm1;
+ ssize_t i, j, M, N, S0, S1;
+ ssize_t r, c, rm1, rp1, cp1, cm1;
M = dims[0]; N = dims[1];
S0 = astrides[0]/sizeof(double);
- S1=astrides[1]/sizeof(double);
- for (i=1; i<M-1; i++) {
- r = i*S0; rp1 = r+S0; rm1 = r-S0;
- for (j=1; j<N-1; j++) {
- c = j*S1; cp1 = j+S1; cm1 = j-S1;
- b[i*N+j] = a[r+c] + \
- (a[rp1+c] + a[rm1+c] + \
- a[r+cp1] + a[r+cm1])*0.5 + \
- (a[rp1+cp1] + a[rp1+cm1] + \
- a[rm1+cp1] + a[rm1+cp1])*0.25;
+ S1 = astrides[1]/sizeof(double);
+ for (i = 1; i < M - 1; i++) {
+ r = i*S0;
+ rp1 = r + S0;
+ rm1 = r - S0;
+ for (j = 1; j < N - 1; j++) {
+ c = j*S1;
+ cp1 = j + S1;
+ cm1 = j - S1;
+ b[i*N + j] = a[r + c] +
+ (a[rp1 + c] + a[rm1 + c] +
+ a[r + cp1] + a[r + cm1])*0.5 +
+ (a[rp1 + cp1] + a[rp1 + cm1] +
+ a[rm1 + cp1] + a[rm1 + cp1])*0.25;
}
}
}