Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: numpy/numpy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: cphvb/numpy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cphvb
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
Loading
Showing with 22,762 additions and 13,644 deletions.
  1. +2 −0 .gitignore
  2. +3 −0 MANIFEST.in
  3. +12 −0 Makefile
  4. +21 −0 cphvb/__init__.py
  5. +60 −0 cphvb/benchmarks/jacobi.py
  6. +60 −0 cphvb/benchmarks/jacobi_stencil.py
  7. +69 −0 cphvb/include/cphvbnumpy.h
  8. +194 −0 cphvb/include/cphvbnumpy_api.h
  9. +75 −0 cphvb/include/cphvbnumpy_types.h
  10. +68 −0 cphvb/setup.py
  11. +94 −0 cphvb/src/arraycollection.c
  12. +46 −0 cphvb/src/arraycollection.h
  13. +144 −0 cphvb/src/arraydata.c
  14. +62 −0 cphvb/src/arraydata.h
  15. +428 −0 cphvb/src/arrayobject.c
  16. +107 −0 cphvb/src/arrayobject.h
  17. +81 −0 cphvb/src/batch.c
  18. +43 −0 cphvb/src/batch.h
  19. +112 −0 cphvb/src/copyinto.c
  20. +42 −0 cphvb/src/copyinto.h
  21. +228 −0 cphvb/src/cphvbnumpymodule.c
  22. +94 −0 cphvb/src/random.c
  23. +47 −0 cphvb/src/random.h
  24. +104 −0 cphvb/src/reduce.c
  25. +53 −0 cphvb/src/reduce.h
  26. +79 −0 cphvb/src/types.c
  27. +118 −0 cphvb/src/types.h
  28. +194 −0 cphvb/src/ufunc.c
  29. +42 −0 cphvb/src/ufunc.h
  30. +69 −0 cphvb/src/vem_interface.c
  31. +54 −0 cphvb/src/vem_interface.h
  32. BIN cphvb/test/datasets/Jacobi_Amatrix.npy
  33. BIN cphvb/test/datasets/Jacobi_Bvector.npy
  34. BIN cphvb/test/datasets/Jacobi_Cvector.npy
  35. +134 −0 cphvb/test/numpytest.py
  36. +28 −0 cphvb/test/test_IO.py
  37. +32 −0 cphvb/test/test_base_array.py
  38. +18 −0 cphvb/test/test_diagonal.py
  39. +22 −0 cphvb/test/test_dot.py
  40. +74 −0 cphvb/test/test_gameoflife.py
  41. +20 −0 cphvb/test/test_identity.py
  42. +48 −0 cphvb/test/test_jacobi.py
  43. +46 −0 cphvb/test/test_jacobi2.py
  44. +56 −0 cphvb/test/test_jacobi_stencil.py
  45. +28 −0 cphvb/test/test_kNN.py
  46. +19 −0 cphvb/test/test_reduce.py
  47. +103 −0 cphvb/test/test_sor.py
  48. +50 −0 cphvb/test/test_ufunc.py
  49. +13 −14 doc/release/1.6.0-notes.rst
  50. +40 −4 doc/source/reference/c-api.array.rst
  51. +24 −24 doc/source/reference/c-api.iterator.rst
  52. +1 −0 doc/source/reference/routines.indexing.rst
  53. +2 −2 doc/source/reference/{routines.poly.rst → routines.polynomials.poly1d.rst}
  54. +16 −0 doc/source/reference/routines.polynomials.polynomial.rst
  55. +14 −0 doc/source/reference/routines.polynomials.rst
  56. +1 −2 doc/source/reference/routines.rst
  57. +48 −3 doc/source/reference/ufuncs.rst
  58. +3 −0 numpy/__init__.py
  59. +126 −28 numpy/add_newdocs.py
  60. +1 −1 numpy/compat/py3k.py
  61. +3 −7 numpy/core/_internal.py
  62. +44 −17 numpy/core/arrayprint.py
  63. +1 −1 numpy/core/code_generators/cversions.txt
  64. +85 −82 numpy/core/code_generators/generate_umath.py
  65. +1 −1 numpy/core/code_generators/numpy_api.py
  66. +25 −12 numpy/core/include/numpy/ndarraytypes.h
  67. +10 −5 numpy/core/include/numpy/ufuncobject.h
  68. +5 −5 numpy/core/numeric.py
  69. +20 −0 numpy/core/setup.py
  70. +14 −2 numpy/core/shape_base.py
  71. +14 −5 numpy/core/src/multiarray/arrayobject.c
  72. +10 −2 numpy/core/src/multiarray/arraytypes.c.src
  73. +13 −2 numpy/core/src/multiarray/buffer.c
  74. +38 −25 numpy/core/src/multiarray/convert.c
  75. +111 −28 numpy/core/src/multiarray/convert_datatype.c
  76. +112 −31 numpy/core/src/multiarray/ctors.c
  77. +2 −2 numpy/core/src/multiarray/dtype_transfer.c
  78. +23 −6 numpy/core/src/multiarray/einsum.c.src
  79. +0 −2 numpy/core/src/multiarray/item_selection.c
  80. +0 −2 numpy/core/src/multiarray/iterators.c
  81. +8 −10 numpy/core/src/multiarray/methods.c
  82. +0 −3 numpy/core/src/multiarray/multiarray_tests.c.src
  83. +75 −65 numpy/core/src/multiarray/multiarraymodule.c
  84. +806 −769 numpy/core/src/multiarray/nditer.c.src
  85. +161 −165 numpy/core/src/multiarray/nditer_pywrap.c
  86. +2 −2 numpy/core/src/multiarray/nditer_pywrap.h
  87. +5 −6 numpy/core/src/multiarray/scalartypes.c.src
  88. +8 −8 numpy/core/src/multiarray/scalartypes.h
  89. +212 −85 numpy/core/src/umath/ufunc_object.c
  90. +1 −0 numpy/core/src/umath/umath_tests.c.src
  91. +10 −1 numpy/core/src/umath/umathmodule.c.src
  92. +28 −0 numpy/core/tests/test_api.py
  93. +47 −0 numpy/core/tests/test_arrayprint.py
  94. +19 −0 numpy/core/tests/test_einsum.py
  95. +35 −2 numpy/core/tests/test_iterator.py
  96. +64 −14 numpy/core/tests/test_multiarray.py
  97. +168 −91 numpy/core/tests/test_numeric.py
  98. +4 −7 numpy/core/tests/test_records.py
  99. +41 −4 numpy/core/tests/test_regression.py
  100. +2 −2 numpy/core/tests/test_scalarmath.py
  101. +14 −0 numpy/core/tests/test_ufunc.py
  102. +7 −2 numpy/core/tests/test_umath.py
  103. +14 −4 numpy/core/tests/test_umath_complex.py
  104. +10 −1 numpy/ctypeslib.py
  105. +7 −0 numpy/distutils/command/build.py
  106. +5 −0 numpy/distutils/command/install_clib.py
  107. +7 −0 numpy/distutils/extension.py
  108. +5 −6 numpy/distutils/fcompiler/__init__.py
  109. +2 −2 numpy/distutils/fcompiler/intel.py
  110. +2 −8 numpy/distutils/intelccompiler.py
  111. +42 −12 numpy/distutils/misc_util.py
  112. +3 −6 numpy/distutils/system_info.py
  113. +22 −18 numpy/doc/misc.py
  114. +30 −1 numpy/f2py/cfuncs.py
  115. +68 −45 numpy/f2py/crackfortran.py
  116. +15 −5 numpy/f2py/f2py2e.py
  117. +7 −2 numpy/f2py/f90mod_rules.py
  118. +23 −14 numpy/f2py/func2subr.py
  119. +3 −1 numpy/f2py/tests/src/array_from_pyobj/wrapmodule.c
  120. +41 −0 numpy/f2py/tests/src/assumed_shape/foo_mod.f90
  121. +30 −0 numpy/f2py/tests/src/size/foo.f90
  122. +6 −1 numpy/f2py/tests/test_assumed_shape.py
  123. +16 −0 numpy/f2py/tests/test_size.py
  124. +8 −2 numpy/lib/_iotools.py
  125. +78 −41 numpy/lib/function_base.py
  126. +100 −59 numpy/lib/npyio.py
  127. +16 −0 numpy/lib/tests/test__iotools.py
  128. +67 −10 numpy/lib/tests/test_function_base.py
  129. +121 −12 numpy/lib/tests/test_io.py
  130. +64 −64 numpy/lib/tests/test_twodim_base.py
  131. +2 −1 numpy/linalg/linalg.py
  132. +6 −6 numpy/linalg/tests/test_linalg.py
  133. +10 −0 numpy/ma/tests/test_regression.py
  134. +7 −4 numpy/polynomial/__init__.py
  135. +33 −17 numpy/polynomial/polytemplate.py
  136. +2 −2 numpy/random/mtrand/distributions.c
  137. +15,592 −11,703 numpy/random/mtrand/mtrand.c
  138. +146 −10 numpy/random/mtrand/mtrand.pyx
  139. +34 −0 numpy/random/mtrand/randomkit.c
  140. +26 −0 numpy/random/mtrand/randomkit.h
  141. +1 −1 numpy/random/tests/test_random.py
  142. +2 −6 numpy/tests/test_ctypeslib.py
  143. +33 −7 pavement.py
  144. +19 −0 release.sh
  145. +16 −21 setup.py
  146. +1 −1 tools/py3tool.py
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -86,3 +86,5 @@ numpy/core/include/numpy/__ufunc_api.h
numpy/core/include/numpy/_numpyconfig.h
numpy/version.py
site.cfg

.DS_Store
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -21,3 +21,6 @@ include doc/Makefile doc/postprocess.py
recursive-include doc/release *
recursive-include doc/source *
recursive-include doc/sphinxext *
recursive-include doc/cython *
recursive-include doc/pyrex *
recursive-include doc/swig *
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
PYTHON?=python
INSTALLDIR?=/opt/cphvb/

all:
$(PYTHON) setup.py build

clean:
rm -Rf build

install:
$(PYTHON) setup.py build
sudo $(PYTHON) setup.py install --prefix $(INSTALLDIR)
21 changes: 21 additions & 0 deletions cphvb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
/*
* Copyright 2011 Mads R. B. Kristensen <madsbk@gmail.com>
*
* This file is part of DistNumPy <https://github.com/distnumpy>.
*
* DistNumPy is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DistNumPy is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DistNumPy. If not, see <http://www.gnu.org/licenses/>.
*/
"""
from setup import build
60 changes: 60 additions & 0 deletions cphvb/benchmarks/jacobi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import sys
import numpy as np
import time
import cphvbnumpy

def cphvb(ary):
if DIST:
cphvbnumpy.handle_array(ary)

def jacobi(A, B, tol=0.005, forcedIter=0):
'''itteratively solving for matrix A with solution vector B
tol = tolerance for dh/h
init_val = array of initial values to use in the solver
'''
h = np.zeros(np.shape(B), float)
dmax = 1.0
n = 0
tmp0 = np.empty(np.shape(A), float)
tmp1 = np.empty(np.shape(B), float)
AD = np.diagonal(A)
cphvb(A)
cphvb(B)
cphvb(h)
cphvb(tmp0)
cphvb(tmp1)
cphvb(AD)
cphvbnumpy.flush()
t1 = time.time()
while (forcedIter and forcedIter > n) or \
(forcedIter == 0 and dmax > tol):
n += 1
np.multiply(A,h,tmp0)
np.add.reduce(tmp0,1,out=tmp1)
tmp2 = AD
np.subtract(B, tmp1, tmp1)
np.divide(tmp1, tmp2, tmp1)
hnew = h + tmp1
np.subtract(hnew,h,tmp2)
np.divide(tmp2,h,tmp1)
np.absolute(tmp1,tmp1)
dmax = np.maximum.reduce(tmp1)
h = hnew

cphvbnumpy.flush()
t2 = time.time()
print 'Iter: ', n, ' size:', np.shape(A), " time:", t2-t1

return h
DIST = int(sys.argv[1])
size = int(sys.argv[2])
iter = int(sys.argv[3])

#A = array([[4, -1, -1, 0], [-1, 4, 0, -1], [-1, 0, 4, -1], [0, -1, -1, 4]], float, dist=d)
#B = array([1,2,0,1], float, dist=d)

A = np.random.random((size,size))
B = np.random.random((size))

C = jacobi(A, B, forcedIter=iter)

60 changes: 60 additions & 0 deletions cphvb/benchmarks/jacobi_stencil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import sys
import numpy as np
import time
import cphvbnumpy

def cphvb(ary):
if DIST:
cphvbnumpy.handle_array(ary)

DIST=int(sys.argv[1])
W = int(sys.argv[2])
H = int(sys.argv[2])
forcedIter = int(sys.argv[3])

full = np.zeros((W+2,H+2), dtype=np.double)
work = np.zeros((W,H), dtype=np.double)
diff = np.zeros((W,H), dtype=np.double)
tmpdelta = np.zeros((W), dtype=np.double)

cphvb(full)
cphvb(work)
cphvb(diff)
cphvb(tmpdelta)

cells = full[1:-1, 1:-1]
up = full[1:-1, 0:-2]
left = full[0:-2, 1:-1]
right = full[2: , 1:-1]
down = full[1:-1, 2: ]

full[:,0] += -273.15
full[:,-1] += -273.15
full[0,:] += 40.0
full[-1,:] += -273.13

cphvbnumpy.flush()
t1 = time.time()
epsilon=W*H*0.010
delta=epsilon+1
i=0
print "HEJ"
while (forcedIter and forcedIter > i) or \
(forcedIter == 0 and epsilon<delta):
i+=1
work[:] = cells
work += up
work += left
work += right
work += down
work *= 0.2
np.subtract(cells,work,diff)
np.absolute(diff, diff)
np.add.reduce(diff,out=tmpdelta)
delta = np.add.reduce(tmpdelta)
cells[:] = work

cphvbnumpy.flush()
timing = time.time() - t1

print 'jacobi_stencil - Iter: ', i, ' size:', np.shape(work), " time:", timing
69 changes: 69 additions & 0 deletions cphvb/include/cphvbnumpy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2011 Mads R. B. Kristensen <madsbk@gmail.com>
*
* This file is part of DistNumPy <https://github.com/distnumpy>.
*
* DistNumPy is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* DistNumPy is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with DistNumPy. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef CPHVBNUMPY_H
#define CPHVBNUMPY_H
#ifdef __cplusplus
extern "C" {
#endif

//Only import when compiling cphvbnumpymodule.c
#ifdef CPHVBNUMPY_MODULE
#include "numpy/ndarraytypes.h"
#include "numpy/arrayobject.h"
#include "numpy/ufuncobject.h"
#endif

/* Retrieval of the cphVB array
*
* @obj The (PyArrayObject *).
* @return The (cphvb_array *).
*/
#define PyCphVB_ARRAY(obj) (((PyArrayObject *)(obj))->cphvb_ary)


//Import the API.
#include "cphvbnumpy_api.h"


//Check that the definitions in numpy are in accordance with cphVB.
#if NPY_BITSOF_SHORT != 16
# error the NPY_BITSOF_INT not 16 bit
#endif
#if NPY_BITSOF_INT != 32
# error the NPY_BITSOF_INT not 32 bit
#endif
#if NPY_BITSOF_LONG != 32 && NPY_BITSOF_LONG != 64
# error the NPY_BITSOF_LONG not 32 or 64 bit
#endif
#if NPY_BITSOF_LONGLONG != 64
# error the NPY_BITSOF_LONGLONG not 64 bit
#endif
#if NPY_BITSOF_FLOAT != 32
# error the NPY_BITSOF_FLOAT not 32 bit
#endif
#if NPY_BITSOF_FLOAT == 64
# error the NPY_BITSOF_FLOAT not 64 bit
#endif

#ifdef __cplusplus
}
#endif

#endif /* !defined(CPHVBNUMPY_H) */
Loading