mirror of https://github.com/pyodide/pyodide.git
Update to Scipy 1.7.3 (#2065)
This commit is contained in:
parent
6f318244f9
commit
5309d21371
|
@ -30,6 +30,7 @@ export PYODIDE_BASE_URL?=./
|
|||
|
||||
# For packages that depend on numpy.
|
||||
# TODO: maybe move this somewhere else?
|
||||
export NUMPY_LIB_BASE=$(PYODIDE_ROOT)/packages/numpy/build/numpy-1.21.4/install/lib/python$(PYMAJOR).$(PYMINOR)/site-packages/numpy/
|
||||
export NUMPY_LIB=$(PYODIDE_ROOT)/packages/numpy/build/numpy-1.21.4/install/lib/python$(PYMAJOR).$(PYMINOR)/site-packages/numpy/core/lib/
|
||||
|
||||
# This environment variable is used for packages to detect if they are built
|
||||
|
|
|
@ -184,7 +184,17 @@ async function runPythonAsync(code, globals) {
|
|||
- {{ Enhancement }} upgraded numpy to 1.21.4
|
||||
{pr}`1934`
|
||||
|
||||
- {{ Fix }} The built-in pwd module of Python, which provides Unix specific
|
||||
- {{ Enhancement }} Upgraded SciPy to 1.7.3. Note that there are still known issues with
|
||||
some SciPy components.
|
||||
{pr}`2065`
|
||||
|
||||
- {{ Enhancement }} Upgraded scikit-learn to version 1.0.2
|
||||
{pr}`2065`
|
||||
|
||||
- {{ Enhancement }} Added threadpoolctl (a dependency of scikit-learn)
|
||||
{pr}`2065`
|
||||
|
||||
- {{ Fix }} The built-in pwd module of Python, which provides a Unix specific
|
||||
feature, is now unvendored.
|
||||
{pr}`1883`
|
||||
|
||||
|
|
|
@ -31,11 +31,7 @@ build:
|
|||
sed -i 's/^ ar /^ $(ARCH)/' **/Makefile
|
||||
sed -i 's/^ ld /^ $(LD)/' **/Makefile
|
||||
|
||||
# We build BLAS/LAPACK only for target.
|
||||
# On host we include -LCLAPACK-3.2.1 path which has no effect on host.
|
||||
# On target it gets rewritten by pywasmcross to the full patch of
|
||||
# blas_WA.a, lapack_WA.a which are linked statically in scipy
|
||||
# in each module that needs them.
|
||||
emmake make -j ${PYODIDE_JOBS:-3} blaslib lapacklib
|
||||
mkdir -p install/lib
|
||||
emcc blas_WA.a lapack_WA.a F2CLIBS/libf2c.a -sSIDE_MODULE -o install/lib/clapack_all.so
|
||||
|
||||
emcc blas_WA.a lapack_WA.a F2CLIBS/libf2c.a -sSIDE_MODULE -o install/lib/clapack_all.so
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package:
|
||||
name: scikit-learn
|
||||
version: 0.22.2
|
||||
version: 1.0.2
|
||||
|
||||
source:
|
||||
url: https://github.com/scikit-learn/scikit-learn/archive/0.22.2.tar.gz
|
||||
sha256: 54ae27be30ef26718c9e517c4c8f23b6af26c66e52cf16d38799ba4262d4fd3b
|
||||
url: https://files.pythonhosted.org/packages/75/44/074b780d8ac0b0899937e9b8ba6d5d8873a71b99aa915219251ef85a8890/scikit-learn-1.0.2.tar.gz
|
||||
sha256: b5870959a5484b614f26d31ca4c17524b1b0317522199dc985c3b4256e030767
|
||||
|
||||
patches:
|
||||
- patches/disable-openmp.patch
|
||||
- patches/0001-Cythonize-_cython_blas.pyx-with-include-path-pointin.patch
|
||||
|
||||
build:
|
||||
cflags: -Wno-implicit-function-declaration
|
||||
|
@ -17,6 +18,7 @@ requirements:
|
|||
- numpy
|
||||
- scipy
|
||||
- joblib
|
||||
- threadpoolctl
|
||||
|
||||
test:
|
||||
imports:
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
From f1d8f0b92b17765a2e8b6ac508cfa77a79fb73a0 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sun, 26 Dec 2021 22:39:25 -0800
|
||||
Subject: [PATCH] Cythonize _cython_blas.pyx with include path pointing to
|
||||
scipy
|
||||
|
||||
---
|
||||
sklearn/utils/setup.py | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/sklearn/utils/setup.py b/sklearn/utils/setup.py
|
||||
index ed78ecc5d..ea1a61b40 100644
|
||||
--- a/sklearn/utils/setup.py
|
||||
+++ b/sklearn/utils/setup.py
|
||||
@@ -2,6 +2,7 @@ import os
|
||||
from os.path import join
|
||||
|
||||
from sklearn._build_utils import gen_from_templates
|
||||
+from Cython.Build import cythonize
|
||||
|
||||
|
||||
def configuration(parent_package="", top_path=None):
|
||||
@@ -18,6 +19,7 @@ def configuration(parent_package="", top_path=None):
|
||||
"sparsefuncs_fast", sources=["sparsefuncs_fast.pyx"], libraries=libraries
|
||||
)
|
||||
|
||||
+ cythonize("sklearn/utils/_cython_blas.pyx", include_path=[f"{os.environ['PYODIDE_ROOT']}/packages/scipy/build/scipy-1.7.3/"])
|
||||
config.add_extension(
|
||||
"_cython_blas", sources=["_cython_blas.pyx"], libraries=libraries
|
||||
)
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,26 +1,48 @@
|
|||
import pytest
|
||||
from conftest import selenium_context_manager
|
||||
|
||||
|
||||
@pytest.mark.driver_timeout(40)
|
||||
def test_scikit_learn(selenium_standalone, request):
|
||||
selenium = selenium_standalone
|
||||
selenium.load_package("scikit-learn")
|
||||
assert (
|
||||
def test_scikit_learn(selenium_module_scope):
|
||||
if selenium_module_scope.browser == "chrome":
|
||||
pytest.xfail("Times out in chrome")
|
||||
with selenium_context_manager(selenium_module_scope) as selenium:
|
||||
selenium.load_package("scikit-learn")
|
||||
assert (
|
||||
selenium.run(
|
||||
"""
|
||||
import numpy as np
|
||||
import sklearn
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
|
||||
rng = np.random.RandomState(42)
|
||||
X = rng.rand(100, 20)
|
||||
y = rng.randint(5, size=100)
|
||||
|
||||
estimator = LogisticRegression(solver='liblinear')
|
||||
estimator.fit(X, y)
|
||||
print(estimator.predict(X))
|
||||
estimator.score(X, y)
|
||||
"""
|
||||
)
|
||||
> 0
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.driver_timeout(40)
|
||||
def test_logistic_regression(selenium_module_scope):
|
||||
if selenium_module_scope.browser == "chrome":
|
||||
pytest.xfail("Times out in chrome")
|
||||
with selenium_context_manager(selenium_module_scope) as selenium:
|
||||
selenium.load_package("scikit-learn")
|
||||
selenium.run(
|
||||
"""
|
||||
import numpy as np
|
||||
import sklearn
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
|
||||
rng = np.random.RandomState(42)
|
||||
X = rng.rand(100, 20)
|
||||
y = rng.randint(5, size=100)
|
||||
|
||||
estimator = LogisticRegression(solver='liblinear')
|
||||
estimator.fit(X, y)
|
||||
print(estimator.predict(X))
|
||||
estimator.score(X, y)
|
||||
"""
|
||||
from sklearn.datasets import load_iris
|
||||
from sklearn.linear_model import LogisticRegression
|
||||
X, y = load_iris(return_X_y=True)
|
||||
clf = LogisticRegression(random_state=0).fit(X, y)
|
||||
print(clf.predict(X[:2, :]))
|
||||
print(clf.predict_proba(X[:2, :]))
|
||||
print(clf.score(X, y))
|
||||
"""
|
||||
)
|
||||
> 0
|
||||
)
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
The biggest issue that comes up in building scipy is that we don't have a good
|
||||
fotran to wasm compiler. Some version of flang classic might work.
|
||||
|
||||
Instead of compiling from fortran directly, we rely on f2c to cross compile
|
||||
the code to C and then compile C to wasm. We rely on f2c both directly and via
|
||||
CLAPACK which is f2c'd LAPACK.
|
||||
|
||||
Unfortunately, f2c only handles fortran 77 code and it doesn't work perfectly
|
||||
even on that. After LAPACK version 3.2 (released in 2008), LAPACK started
|
||||
adding methods that use newer fortran features, so they cannot be f2c'd. Hence
|
||||
it's unlikely that new versions of CLAPACK will be released and we can't use
|
||||
any newer version of CLAPACK.
|
||||
|
||||
Scipy is built based on a newer version of CLAPACK and I couldn't figure out
|
||||
how to remove the newer functions. They cause dynamic linking errors when
|
||||
scipy is imported. To find the list of problem functions I used:
|
||||
|
||||
```sh
|
||||
wasm-objdump clapack_all.so -d | sed -n 's/.*func.*<\(.*\)>:/\1/p' | sort -u > clapack_exports.txt
|
||||
```
|
||||
|
||||
to list the symbols exported from our clapack and
|
||||
|
||||
```
|
||||
wasm-objdump _flapack.so -d | sed -E -n 's/.*global.get [0-9]* <([a-z]*_?)>/\1/p' | sort -u > symbols.txt
|
||||
```
|
||||
|
||||
to list the symbols that `_flapack.so` expects to see. There are 36 symbols in
|
||||
this list. Conveniently, LAPACK defines one function per file, so I just
|
||||
download a copy of LAPACK and cat these functions into
|
||||
`scipy/linalg/src/lapack_deprecations/cgegv.f` which is chosen arbitrarily from
|
||||
the `.f` source files that are linked into `_flapack.so` (there aren't that many
|
||||
options though). Using an existing file allows us to avoid fiddling with build
|
||||
scripts. Of the 36 missing symbol, 32 of them are written in Fortran 77 and work
|
||||
fine. The remaining 4 need removing but I couldn't figure out how to take them
|
||||
out in any sensible way (I can't understand all the layers of codegen that
|
||||
happen in scipy), so I give them do-nothing definitions, and then in the build
|
||||
script remove lines containing them with `sed`.
|
||||
|
||||
Another big problem with f2c is that it cannot handle implicit casts of function
|
||||
arguments, because it tries to guess the types of the arguments of the function
|
||||
being called based on the types of the arguments at the call site. There are two
|
||||
distinct versions of this:
|
||||
|
||||
1. casts between number types -- we deal with this automatically in
|
||||
`fix_inconsistent_decls` in `_f2c_fixes.py`
|
||||
2. casts between char\* and int -- this is too annoying to deal with
|
||||
automatically, so we write manual patches.
|
||||
|
||||
Type 1: the fortran equivalent of the following C code:
|
||||
|
||||
```C
|
||||
double f(double x){
|
||||
return x + 5;
|
||||
}
|
||||
|
||||
double g(int x){
|
||||
return f(x);
|
||||
}
|
||||
```
|
||||
|
||||
gets f2c'd to
|
||||
|
||||
```C
|
||||
double f(double x){
|
||||
return x + 5;
|
||||
}
|
||||
|
||||
double g(int x){
|
||||
double f(int);
|
||||
return f(x);
|
||||
}
|
||||
```
|
||||
|
||||
When we try to compile this, we get an error saying that f has been declared
|
||||
with two different types.
|
||||
|
||||
Type 2: For each string argument, the Fortran ABI adds arguments at the end of
|
||||
the argument list. LAPACK never declares functions as taking strings, preferring
|
||||
to call them integers:
|
||||
|
||||
```C
|
||||
int some_lapack_func(int *some_string, int *some_string_length){
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
But then when we call it: `some_lapack_func("a string here", 14);` the f2c'd
|
||||
version looks like:
|
||||
|
||||
```C
|
||||
int str_len = 14;
|
||||
int some_lapack_func(int *some_string, int *some_string_length, fortranlen some_string_length_again);
|
||||
some_lapack_func("a string here", &str_len, 14);
|
||||
```
|
|
@ -1,60 +1,105 @@
|
|||
package:
|
||||
name: scipy
|
||||
version: 0.17.1
|
||||
version: 1.7.3 # when updating version make sure to update pip install scipy==1.7.3 below too.
|
||||
|
||||
# See extra explanation in info.md
|
||||
#
|
||||
# For future reference: if you see the following errors:
|
||||
# Declaration error: adjustable dimension on non-argument
|
||||
# or:
|
||||
# nonconstant array size
|
||||
# you are trying to compile code that isn't written to the fortran 77 standard.
|
||||
# The line number in the error points to the last line of the problematic
|
||||
# subroutine. Try deleting it.
|
||||
|
||||
source:
|
||||
# We can't use the version from PyPI as it includes Cythonized files
|
||||
# generated with an older Cython that does not support Python 3.7
|
||||
# This requires,
|
||||
# pip install Cython Tempita
|
||||
# on the host for the build
|
||||
url: https://github.com/scipy/scipy/archive/v0.17.1.tar.gz
|
||||
sha256: bf22383d9e2526ffdc53a6c7d3d66dab45a86291ed35d8e281bd1a5d2c34187b
|
||||
url: https://files.pythonhosted.org/packages/61/67/1a654b96309c991762ee9bc39c363fc618076b155fe52d295211cf2536c7/scipy-1.7.3.tar.gz
|
||||
sha256: ab5875facfdef77e0a47d5fd39ea178b58e60e454a4c85aa1e52fcb80db7babf
|
||||
|
||||
patches:
|
||||
# these patches can be found as commits in
|
||||
# https://github.com/rth/scipy/tree/0.17.1-pyodide
|
||||
# on top of the v0.17.1 tag
|
||||
- patches/fix-blas.patch
|
||||
- patches/fix-build-gcc5-a80460.patch
|
||||
- patches/force_malloc.patch
|
||||
- patches/disable_scipy_stats_mvn.patch
|
||||
- patches/skip-fortran-fails-to-link.patch
|
||||
- patches/skip_ellip_harm_2_pyx_ctypes.patch
|
||||
- patches/add-lapack_extras-to-flapack.patch
|
||||
- patches/convert-xerrwv-message-arg-from-int-to-str.patch
|
||||
- patches/disable-blas-detection.patch
|
||||
- patches/fix-fortran-files-minpack.patch
|
||||
- patches/gemm_-no-const.patch
|
||||
- patches/make-int-return-values.patch
|
||||
- patches/add-missing-extern.patch
|
||||
- patches/fix-typo-flapack-pyf.patch
|
||||
- patches/remove-cuncsd-dorcsd-sorcsd-zuncsd.patch
|
||||
- patches/remove-mvnun-not-fortran-77-compliant.patch
|
||||
- patches/sasum-returns-double-not-float.patch
|
||||
- patches/skip-fortran-fails-to-link.patch
|
||||
- patches/rename-_page_trend_test.patch
|
||||
|
||||
build:
|
||||
# set linker and C flags to error on anything to do with function declarations being wrong.
|
||||
# In webassembly, any conflicts mean that a randomly selected 50% of calls to the function
|
||||
# will fail. Better to fail at compile or link time.
|
||||
cflags: |
|
||||
-I $(PYODIDE_ROOT)/packages/numpy/config
|
||||
-I$(PYODIDE_ROOT)/packages/numpy/config
|
||||
-I$(PYODIDE_ROOT)/packages/CLAPACK/build/CLAPACK-3.2.1/INCLUDE
|
||||
-I$(PYODIDE_ROOT)/packages/.artifacts/include/
|
||||
-I$(PYODIDE_ROOT)/packages/.artifacts/pythran/
|
||||
-DUNDERSCORE_G77
|
||||
-Werror=implicit-function-declaration
|
||||
-Werror=mismatched-parameter-types
|
||||
-Werror=mismatched-return-types
|
||||
-Wno-return-type
|
||||
ldflags: |
|
||||
-L$(NUMPY_LIB)
|
||||
-L$(NUMPY_LIB_BASE)/random/lib
|
||||
-Wl,--fatal-warnings
|
||||
# IMPORTANT: Other locations important in scipy build process:
|
||||
# There are two files built in the "capture" pass that need patching:
|
||||
# _blas_subroutines.h, and _cython
|
||||
# Scipy has a bunch of custom logic implemented in
|
||||
# pyodide-build/pyodide_build/_f2c_fixes.py.
|
||||
script: |
|
||||
# Some fixes were extracted from patches/make-int-return-values.patch as regex.
|
||||
pip install scipy==1.7.3 pybind11[global] pythran
|
||||
pip install --upgrade pybind11[global] pythran -t $PYODIDE_ROOT/packages/.artifacts/
|
||||
# We get linker errors because the following 36 functions are missing
|
||||
# Copying them from a more recent LAPACK seems to work fine.
|
||||
wget https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.10.0.tar.gz
|
||||
tar xzf v3.10.0.tar.gz
|
||||
cd lapack-3.10.0/SRC
|
||||
cat \
|
||||
cgemqrt.f cgeqrfp.f cgeqrt.f clahqr.f csyconv.f csyconvf.f csyconvf_rook.f ctpmqrt.f ctpqrt.f \
|
||||
dgemqrt.f dgeqrfp.f dgeqrt.f dlahqr.f dsyconv.f dsyconvf.f dsyconvf_rook.f dtpmqrt.f dtpqrt.f \
|
||||
sgemqrt.f sgeqrfp.f sgeqrt.f slahqr.f ssyconv.f ssyconvf.f ssyconvf_rook.f stpmqrt.f stpqrt.f \
|
||||
zgemqrt.f zgeqrfp.f zgeqrt.f zlahqr.f zsyconv.f zsyconvf.f zsyconvf_rook.f ztpmqrt.f ztpqrt.f \
|
||||
>> ../../scipy/linalg/lapack_extras.f
|
||||
cd ../..
|
||||
# The additional four functions cuncsd, dorcsd, sorcsd, and zuncsd are also
|
||||
# missing but they use features of Fortran that aren't Fortran 77 compatible
|
||||
# so f2c can't handle them. We stub them with C definitions that do nothing.
|
||||
# These stubs come from f2cpatches/wrap_dummy_g77_abi.patch
|
||||
|
||||
# Change many functions that return void into functions that return int
|
||||
find scipy -name "*.c*" | xargs sed -i 's/extern void F_FUNC/extern int F_FUNC/g'
|
||||
sed -i 's/void F_FUNC/int F_FUNC/g' scipy/odr/__odrpack.c
|
||||
sed -i 's/extern void/extern int/g' scipy/optimize/__minpack.h scipy/fftpack/src/zfftnd.c scipy/fftpack/src/zrfft.c
|
||||
sed -i 's/void f_/int f_/g' scipy/cluster/cluster_blas.pxd
|
||||
sed -i 's/void @pref/int @pref/g' scipy/fftpack/src/dct.c.src scipy/fftpack/src/dst.c.src
|
||||
sed -i 's/^void/int/g' scipy/interpolate/src/__fitpack.h scipy/integrate/__quadpack.h scipy/fftpack/src/drfft.c scipy/fftpack/src/zfft.c
|
||||
sed -i 's/static void/static int/g' scipy/interpolate/src/__fitpack.h
|
||||
sed -i 's/ILAENV/ILAENZ/g' scipy/linalg/src/calc_lwork.f
|
||||
# Regenerate header files after make-int-return-values patch to fix return
|
||||
# types of f2c functions.
|
||||
echo "Regenerating cython wrappers"
|
||||
cd scipy/linalg
|
||||
python _cython_wrapper_generators.py
|
||||
cd ../..
|
||||
sed -i 's/extern void/extern int/g' scipy/optimize/__minpack.h
|
||||
sed -i 's/^void/int/g' scipy/interpolate/src/_fitpackmodule.c
|
||||
sed -i 's/void/int/g' scipy/linalg/cython_blas_signatures.txt
|
||||
|
||||
# Missing declaration from cython_lapack_signatures.txt
|
||||
echo "void ilaenv(int *ispec, char *name, char *opts, int *n1, int *n2, int *n3, int *n4)" \
|
||||
>> scipy/linalg/cython_lapack_signatures.txt
|
||||
|
||||
# Input error causes "duplicate symbol" linker errors. Empty out the file.
|
||||
echo "" > scipy/sparse/linalg/dsolve/SuperLU/SRC/input_error.c
|
||||
echo 'import sys' >> scipy/__init__.py
|
||||
echo 'if "pyodide_js" in sys.modules:' >> scipy/__init__.py
|
||||
echo ' from pyodide_js._module import loadDynamicLibrary' >> scipy/__init__.py
|
||||
echo ' loadDynamicLibrary("/lib/python3.9/site-packages/scipy/linalg/_flapack.so")' >> scipy/__init__.py
|
||||
|
||||
prereplay: |
|
||||
sed -i 's/void F_FUNC/int F_FUNC/g' scipy/linalg/_lapack_subroutines.h
|
||||
sed -i 's/void F_FUNC/int F_FUNC/g' scipy/linalg/_blas_subroutines.h
|
||||
find -name '*.c' | xargs sed -i 's/extern void F_WRAPPEDFUNC/extern int F_WRAPPEDFUNC/g'
|
||||
find -name '*.c' | xargs sed -i 's/void (\*f2py_func)/int (*f2py_func)/g'
|
||||
find -name '*.c' | xargs sed -i 's/static void cb_/static int cb_/g'
|
||||
find -name '*.c' | xargs sed -i 's/typedef void(\*cb_/typedef int(*cb_/g'
|
||||
sed -i 's/,size_t//' build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/scipy/linalg/_flapackmodule.c
|
||||
sed -i 's/,slen([a-z]*))/)/g' build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/scipy/linalg/_flapackmodule.c
|
||||
sed -i 's/ float (\*f2py_func)/ double (\*f2py_func)/g' build/src.linux-x86_64-3.9/build/src.linux-x86_64-3.9/scipy/linalg/_fblasmodule.c
|
||||
|
||||
requirements:
|
||||
run:
|
||||
|
@ -65,14 +110,38 @@ test:
|
|||
imports:
|
||||
- scipy
|
||||
- scipy.cluster
|
||||
- scipy.cluster.vq
|
||||
- scipy.cluster.hierarchy
|
||||
- scipy.constants
|
||||
- scipy.fft
|
||||
- scipy.fftpack
|
||||
- scipy.odr
|
||||
- scipy.sparse
|
||||
- scipy.interpolate
|
||||
- scipy.integrate
|
||||
- scipy.interpolate
|
||||
- scipy.io
|
||||
- scipy.io.arff
|
||||
- scipy.io.matlab
|
||||
- scipy.io.wavfile
|
||||
- scipy.linalg
|
||||
- scipy.linalg.blas
|
||||
- scipy.linalg.cython_blas
|
||||
- scipy.linalg.lapack
|
||||
- scipy.linalg.cython_lapack
|
||||
- scipy.linalg.interpolative
|
||||
- scipy.misc
|
||||
- scipy.ndimage
|
||||
- scipy.odr
|
||||
- scipy.optimize
|
||||
- scipy.signal
|
||||
- scipy.signal.windows
|
||||
- scipy.sparse
|
||||
- scipy.sparse.linalg
|
||||
- scipy.sparse.csgraph
|
||||
- scipy.spatial
|
||||
- scipy.spatial.distance
|
||||
- scipy.spatial.transform
|
||||
- scipy.special
|
||||
- scipy.stats
|
||||
- scipy.stats.contingency
|
||||
- scipy.stats.distributions
|
||||
- scipy.stats.mstats
|
||||
- scipy.stats.qmc
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
From 117b00d72c0472eb6a33e8fcbf17e3bfe3337a88 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Fri, 31 Dec 2021 22:27:07 -0800
|
||||
Subject: [PATCH] Add lapack_extras to linalg/setup.py
|
||||
|
||||
---
|
||||
scipy/linalg/setup.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/scipy/linalg/setup.py b/scipy/linalg/setup.py
|
||||
index 2f0ef0a48..d384081a2 100644
|
||||
--- a/scipy/linalg/setup.py
|
||||
+++ b/scipy/linalg/setup.py
|
||||
@@ -43,7 +43,7 @@ def configuration(parent_package='', top_path=None):
|
||||
ext._pre_build_hook = blas_ilp64_pre_build_hook(lapack_ilp64_opt)
|
||||
|
||||
# flapack:
|
||||
- sources = ['flapack.pyf.src']
|
||||
+ sources = ['flapack.pyf.src', 'lapack_extras.f']
|
||||
sources += get_g77_abi_wrappers(lapack_opt)
|
||||
dep_pfx = join('src', 'lapack_deprecations')
|
||||
deprecated_lapack_routines = [join(dep_pfx, c + 'gegv.f') for c in 'cdsz']
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
Add a missing extern in specfunc_wrappers.c
|
||||
|
||||
--- a/scipy/special/specfun_wrappers.c
|
||||
+++ b/scipy/special/specfun_wrappers.c
|
||||
@@ -35,6 +35,7 @@
|
||||
extern void F_FUNC(itairy,ITAIRY)(double*,double*,double*,double*,double*);
|
||||
extern void F_FUNC(e1xb,E1XB)(double*,double*);
|
||||
extern void F_FUNC(e1z,E1Z)(npy_cdouble*,npy_cdouble*);
|
||||
+extern void F_FUNC(eixz,EIXZ)(npy_cdouble*,npy_cdouble*);
|
||||
extern void F_FUNC(eix,EIX)(double*,double*);
|
||||
extern void F_FUNC(cerror,CERROR)(npy_cdouble*,npy_cdouble*);
|
||||
extern void F_FUNC(stvh0,STVH0)(double*,double*);
|
|
@ -0,0 +1,30 @@
|
|||
From 109051fc810881a7291b47ba9353a69a36b600e3 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sat, 25 Dec 2021 18:04:18 -0800
|
||||
Subject: [PATCH] int to string
|
||||
|
||||
f2c does not handle implicit casts of function arguments correctly. The msg
|
||||
argument of `xerrwv` is defined to be an `int *`, and then implicitly cast
|
||||
from a string at the call site. This doesn't work correctly.
|
||||
|
||||
We redefine the type of the first argument to be string to fix the problem.
|
||||
|
||||
---
|
||||
scipy/integrate/odepack/xerrwv.f | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/scipy/integrate/odepack/xerrwv.f b/scipy/integrate/odepack/xerrwv.f
|
||||
index 7e180e4f8..b940bb702 100644
|
||||
--- a/scipy/integrate/odepack/xerrwv.f
|
||||
+++ b/scipy/integrate/odepack/xerrwv.f
|
||||
@@ -1,5 +1,6 @@
|
||||
subroutine xerrwv (msg, nmes, nerr, level, ni, i1, i2, nr, r1, r2)
|
||||
- integer msg, nmes, nerr, level, ni, i1, i2, nr,
|
||||
+ character msg*1
|
||||
+ integer nmes, nerr, level, ni, i1, i2, nr,
|
||||
1 i, lun, lunit, mesflg, ncpw, nch, nwds
|
||||
double precision r1, r2
|
||||
dimension msg(nmes)
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
commit 7352fc4a977a3414cf3194faf6ef990638a6329c
|
||||
Author: Roman Yurchak <rth.yurchak@gmail.com>
|
||||
Date: Sat Feb 27 11:13:29 2021 +0100
|
||||
|
||||
disable-blas-detection.patch
|
||||
|
||||
BLAS and LAPACK aren't available on host because we only cross compile these
|
||||
libraries (see CLAPACK/meta.yaml). Scipy tries to detect these libraries and
|
||||
if it fails to find them errors out the build. But we have them installed
|
||||
correctly for our target, so we just disable this detection mechanism.
|
||||
|
||||
diff --git a/setup.py b/setup.py
|
||||
index 0e11de60f..8c28c613d 100755
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -484,7 +484,7 @@ def configuration(parent_package='', top_path=None):
|
||||
|
||||
lapack_opt = get_info('lapack_opt')
|
||||
|
||||
- if not lapack_opt:
|
||||
+ if not lapack_opt and False:
|
||||
if sys.platform == "darwin":
|
||||
msg = ('No BLAS/LAPACK libraries found. '
|
||||
'Note: Accelerate is no longer supported.')
|
|
@ -1,39 +0,0 @@
|
|||
commit d6740caa7400105a578ace74f8c25bbb3434178c
|
||||
Author: Roman Yurchak <rth.yurchak@pm.me>
|
||||
Date: Wed Oct 10 14:47:12 2018 +0200
|
||||
|
||||
Disable scipy.stats.mvn
|
||||
|
||||
diff --git a/scipy/stats/kde.py b/scipy/stats/kde.py
|
||||
index 7c702a038..8b0ab0254 100644
|
||||
--- a/scipy/stats/kde.py
|
||||
+++ b/scipy/stats/kde.py
|
||||
@@ -32,7 +32,10 @@ import numpy as np
|
||||
from numpy.random import randint, multivariate_normal
|
||||
|
||||
# Local imports.
|
||||
-from . import mvn
|
||||
+try:
|
||||
+ from . import mvn
|
||||
+except ImportError:
|
||||
+ mvn = None
|
||||
|
||||
|
||||
__all__ = ['gaussian_kde']
|
||||
diff --git a/scipy/stats/setup.py b/scipy/stats/setup.py
|
||||
index f1a02df4e..7366ec12d 100755
|
||||
--- a/scipy/stats/setup.py
|
||||
+++ b/scipy/stats/setup.py
|
||||
@@ -32,9 +32,9 @@ def configuration(parent_package='',top_path=None):
|
||||
)
|
||||
|
||||
# add mvn module
|
||||
- config.add_extension('mvn',
|
||||
- sources=['mvn.pyf','mvndst.f'],
|
||||
- )
|
||||
+ #config.add_extension('mvn',
|
||||
+ # sources=['mvn.pyf','mvndst.f'],
|
||||
+ #)
|
||||
|
||||
return config
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
commit f03d85c00ae993c3c87a5a7b2ea0c1215f57ee04
|
||||
Author: Roman Yurchak <rth.yurchak@pm.me>
|
||||
Date: Mon Oct 8 10:53:11 2018 +0200
|
||||
|
||||
Partial fixes for BLAS/LAPACK
|
||||
|
||||
diff --git a/scipy/linalg/setup.py b/scipy/linalg/setup.py
|
||||
index 2c9b9ba22..e8c7336d5 100755
|
||||
--- a/scipy/linalg/setup.py
|
||||
+++ b/scipy/linalg/setup.py
|
||||
@@ -14,7 +14,13 @@ def configuration(parent_package='', top_path=None):
|
||||
|
||||
config = Configuration('linalg', parent_package, top_path)
|
||||
|
||||
- lapack_opt = get_info('lapack_opt')
|
||||
+ lapack_opt = { # libraries will be auto-generated by pywasmcross
|
||||
+ 'libraries': [],
|
||||
+ 'include_dirs': [],
|
||||
+ 'library_dirs': ['../../../CLAPACK/build/CLAPACK-3.2.1/'],
|
||||
+ 'language': 'f77',
|
||||
+ 'define_macros': [('NO_ATLAS_INFO', 1),
|
||||
+ ('HAVE_CBLAS', None)]}
|
||||
|
||||
if not lapack_opt:
|
||||
raise NotFoundError('no lapack/blas resources found')
|
||||
@@ -117,9 +123,22 @@ def configuration(parent_package='', top_path=None):
|
||||
fnames = split_fortran_files(join(dirname, 'src', 'id_dist', 'src'),
|
||||
routines_to_split)
|
||||
fnames = [join('src', 'id_dist', 'src', f) for f in fnames]
|
||||
- config.add_extension('_interpolative', fnames + ["interpolative.pyf"],
|
||||
- extra_info=lapack_opt
|
||||
- )
|
||||
+ # TODO: The following fails with,
|
||||
+ # scipy/linalg/src/id_dist/src/idd_sfft.c:114:22: error: conflicting types for 'idd_sffti1__'
|
||||
+ # /* Subroutine */ int idd_sffti1__(integer *ind, integer *n, doublereal *wsave)
|
||||
+ # ^
|
||||
+ # scipy/linalg/src/id_dist/src/idd_sfft.c:72:33: note: previous declaration is here
|
||||
+ # extern /* Subroutine */ int idd_sffti1__(integer *, integer *,
|
||||
+ # ^
|
||||
+ # scipy/linalg/src/id_dist/src/idd_sfft.c:371:22: error: conflicting types for 'idd_sfft1__'
|
||||
+ # /* Subroutine */ int idd_sfft1__(integer *ind, integer *n, doublereal *v,
|
||||
+ # ^
|
||||
+ # scipy/linalg/src/id_dist/src/idd_sfft.c:311:33: note: previous declaration is here
|
||||
+ # extern /* Subroutine */ int idd_sfft1__(integer *, integer *, doublereal *<Paste>
|
||||
+ #
|
||||
+ #config.add_extension('_interpolative', fnames + ["interpolative.pyf"],
|
||||
+ # extra_info=lapack_opt
|
||||
+ # )
|
||||
|
||||
# _calc_lwork:
|
||||
config.add_extension('_calc_lwork',
|
||||
diff --git a/scipy/sparse/linalg/eigen/arpack/setup.py b/scipy/sparse/linalg/eigen/arpack/setup.py
|
||||
index a8175a9d5..88a717fe6 100755
|
||||
--- a/scipy/sparse/linalg/eigen/arpack/setup.py
|
||||
+++ b/scipy/sparse/linalg/eigen/arpack/setup.py
|
||||
@@ -11,7 +11,13 @@ def configuration(parent_package='',top_path=None):
|
||||
|
||||
config = Configuration('arpack',parent_package,top_path)
|
||||
|
||||
- lapack_opt = get_info('lapack_opt')
|
||||
+ lapack_opt = { # libraries will be auto-generated by pywasmcross
|
||||
+ 'libraries': [],
|
||||
+ 'include_dirs': [],
|
||||
+ 'library_dirs': ['../../../CLAPACK/build/CLAPACK-3.2.1/'],
|
||||
+ 'language': 'f77',
|
||||
+ 'define_macros': [('NO_ATLAS_INFO', 1),
|
||||
+ ('HAVE_CBLAS', None)]}
|
||||
|
||||
if not lapack_opt:
|
||||
raise NotFoundError('no lapack/blas resources found')
|
||||
diff --git a/scipy/sparse/linalg/isolve/setup.py b/scipy/sparse/linalg/isolve/setup.py
|
||||
index becb9237a..707e3f49d 100755
|
||||
--- a/scipy/sparse/linalg/isolve/setup.py
|
||||
+++ b/scipy/sparse/linalg/isolve/setup.py
|
||||
@@ -11,7 +11,13 @@ def configuration(parent_package='',top_path=None):
|
||||
|
||||
config = Configuration('isolve',parent_package,top_path)
|
||||
|
||||
- lapack_opt = get_info('lapack_opt')
|
||||
+ lapack_opt = { # libraries will be auto-generated by pywasmcross
|
||||
+ 'libraries': [],
|
||||
+ 'include_dirs': [],
|
||||
+ 'library_dirs': ['../../../CLAPACK/build/CLAPACK-3.2.1/'],
|
||||
+ 'language': 'f77',
|
||||
+ 'define_macros': [('NO_ATLAS_INFO', 1),
|
||||
+ ('HAVE_CBLAS', None)]}
|
||||
|
||||
if not lapack_opt:
|
||||
raise NotFoundError('no lapack/blas resources found')
|
|
@ -1,54 +0,0 @@
|
|||
commit a80460f1b45035d34575866e6394107396ac62e2
|
||||
Author: Michael Danilov <mike402@users.noreply.github.com>
|
||||
Date: Thu Apr 20 18:08:39 2017 +0200
|
||||
|
||||
Fix build with GCC5.
|
||||
|
||||
diff --git a/scipy/odr/odrpack/d_lpkbls.f b/scipy/odr/odrpack/d_lpkbls.f
|
||||
index 324b7a8a2..1e6624d63 100644
|
||||
--- a/scipy/odr/odrpack/d_lpkbls.f
|
||||
+++ b/scipy/odr/odrpack/d_lpkbls.f
|
||||
@@ -136,8 +136,8 @@ C***FIRST EXECUTABLE STATEMENT DAXPY
|
||||
|
||||
|
||||
IF(N.LE.0.OR.DA.EQ.0.D0) RETURN
|
||||
- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5
|
||||
- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20
|
||||
GOTO 60
|
||||
5 CONTINUE
|
||||
|
||||
@@ -483,8 +483,8 @@ C***FIRST EXECUTABLE STATEMENT DCOPY
|
||||
|
||||
|
||||
IF(N.LE.0)RETURN
|
||||
- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5
|
||||
- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20
|
||||
GOTO 60
|
||||
5 CONTINUE
|
||||
|
||||
@@ -589,8 +589,8 @@ C***FIRST EXECUTABLE STATEMENT DDOT
|
||||
|
||||
DDOT = 0.D0
|
||||
IF(N.LE.0)RETURN
|
||||
- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5
|
||||
- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20
|
||||
GOTO 60
|
||||
5 CONTINUE
|
||||
|
||||
@@ -1772,8 +1772,8 @@ C***FIRST EXECUTABLE STATEMENT DSWAP
|
||||
|
||||
|
||||
IF(N.LE.0)RETURN
|
||||
- IF (INCX.EQ.INCY) IF(INCX.lt.1) GOTO 5
|
||||
- IF (INCX.EQ.INCY) IF(INCX.eq.1) GOTO 20
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.lt.1) GOTO 5
|
||||
+ IF (INCX.EQ.INCY .AND. INCX.eq.1) GOTO 20
|
||||
GOTO 60
|
||||
5 CONTINUE
|
||||
|
|
@ -0,0 +1,253 @@
|
|||
diff --git a/scipy/optimize/minpack/chkder.f b/scipy/optimize/minpack/chkder.f
|
||||
index 0657ab56a..29578fc41 100644
|
||||
--- a/scipy/optimize/minpack/chkder.f
|
||||
+++ b/scipy/optimize/minpack/chkder.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err)
|
||||
+ subroutine chkder(m,n,x,fvec,fjac,ldfjac,xp,fvecp,mode,err)
|
||||
integer m,n,ldfjac,mode
|
||||
double precision x(n),fvec(m),fjac(ldfjac,n),xp(n),fvecp(m),
|
||||
* err(m)
|
||||
diff --git a/scipy/optimize/minpack/dogleg.f b/scipy/optimize/minpack/dogleg.f
|
||||
index d9626c911..b812f1966 100644
|
||||
--- a/scipy/optimize/minpack/dogleg.f
|
||||
+++ b/scipy/optimize/minpack/dogleg.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2)
|
||||
+ subroutine dogleg(n,r,lr,diag,qtb,delta,x,wa1,wa2)
|
||||
integer n,lr
|
||||
double precision delta
|
||||
double precision r(lr),diag(n),qtb(n),x(n),wa1(n),wa2(n)
|
||||
diff --git a/scipy/optimize/minpack/dpmpar.f b/scipy/optimize/minpack/dpmpar.f
|
||||
index 3fd3b4ef8..cb6545a92 100644
|
||||
--- a/scipy/optimize/minpack/dpmpar.f
|
||||
+++ b/scipy/optimize/minpack/dpmpar.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *double precision function dpmpar(i)
|
||||
+ double precision function dpmpar(i)
|
||||
integer i
|
||||
c **********
|
||||
c
|
||||
diff --git a/scipy/optimize/minpack/enorm.f b/scipy/optimize/minpack/enorm.f
|
||||
index 21557c147..2cb5b607e 100644
|
||||
--- a/scipy/optimize/minpack/enorm.f
|
||||
+++ b/scipy/optimize/minpack/enorm.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *double precision function enorm(n,x)
|
||||
+ double precision function enorm(n,x)
|
||||
integer n
|
||||
double precision x(n)
|
||||
c **********
|
||||
diff --git a/scipy/optimize/minpack/fdjac1.f b/scipy/optimize/minpack/fdjac1.f
|
||||
index 2a7d84cc1..031ed4652 100644
|
||||
--- a/scipy/optimize/minpack/fdjac1.f
|
||||
+++ b/scipy/optimize/minpack/fdjac1.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,
|
||||
+ subroutine fdjac1(fcn,n,x,fvec,fjac,ldfjac,iflag,ml,mu,epsfcn,
|
||||
* wa1,wa2)
|
||||
integer n,ldfjac,iflag,ml,mu
|
||||
double precision epsfcn
|
||||
diff --git a/scipy/optimize/minpack/fdjac2.f b/scipy/optimize/minpack/fdjac2.f
|
||||
index 5f4c1338f..218ab94c1 100644
|
||||
--- a/scipy/optimize/minpack/fdjac2.f
|
||||
+++ b/scipy/optimize/minpack/fdjac2.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa)
|
||||
+ subroutine fdjac2(fcn,m,n,x,fvec,fjac,ldfjac,iflag,epsfcn,wa)
|
||||
integer m,n,ldfjac,iflag
|
||||
double precision epsfcn
|
||||
double precision x(n),fvec(m),fjac(ldfjac,n),wa(m)
|
||||
diff --git a/scipy/optimize/minpack/hybrd.f b/scipy/optimize/minpack/hybrd.f
|
||||
index 75f450c9c..fc0b4c26a 100644
|
||||
--- a/scipy/optimize/minpack/hybrd.f
|
||||
+++ b/scipy/optimize/minpack/hybrd.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,diag,
|
||||
+ subroutine hybrd(fcn,n,x,fvec,xtol,maxfev,ml,mu,epsfcn,diag,
|
||||
* mode,factor,nprint,info,nfev,fjac,ldfjac,r,lr,
|
||||
* qtf,wa1,wa2,wa3,wa4)
|
||||
integer n,maxfev,ml,mu,mode,nprint,info,nfev,ldfjac,lr
|
||||
diff --git a/scipy/optimize/minpack/hybrd1.f b/scipy/optimize/minpack/hybrd1.f
|
||||
index 87660fe18..c0a859275 100644
|
||||
--- a/scipy/optimize/minpack/hybrd1.f
|
||||
+++ b/scipy/optimize/minpack/hybrd1.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
|
||||
+ subroutine hybrd1(fcn,n,x,fvec,tol,info,wa,lwa)
|
||||
integer n,info,lwa
|
||||
double precision tol
|
||||
double precision x(n),fvec(n),wa(lwa)
|
||||
diff --git a/scipy/optimize/minpack/hybrj.f b/scipy/optimize/minpack/hybrj.f
|
||||
index 4f676832e..3070dad3f 100644
|
||||
--- a/scipy/optimize/minpack/hybrj.f
|
||||
+++ b/scipy/optimize/minpack/hybrj.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode,
|
||||
+ subroutine hybrj(fcn,n,x,fvec,fjac,ldfjac,xtol,maxfev,diag,mode,
|
||||
* factor,nprint,info,nfev,njev,r,lr,qtf,wa1,wa2,
|
||||
* wa3,wa4)
|
||||
integer n,ldfjac,maxfev,mode,nprint,info,nfev,njev,lr
|
||||
diff --git a/scipy/optimize/minpack/hybrj1.f b/scipy/optimize/minpack/hybrj1.f
|
||||
index afa9d80f1..9f51c4965 100644
|
||||
--- a/scipy/optimize/minpack/hybrj1.f
|
||||
+++ b/scipy/optimize/minpack/hybrj1.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa)
|
||||
+ subroutine hybrj1(fcn,n,x,fvec,fjac,ldfjac,tol,info,wa,lwa)
|
||||
integer n,ldfjac,info,lwa
|
||||
double precision tol
|
||||
double precision x(n),fvec(n),fjac(ldfjac,n),wa(lwa)
|
||||
diff --git a/scipy/optimize/minpack/lmder.f b/scipy/optimize/minpack/lmder.f
|
||||
index 684925592..8797d8bed 100644
|
||||
--- a/scipy/optimize/minpack/lmder.f
|
||||
+++ b/scipy/optimize/minpack/lmder.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
|
||||
+ subroutine lmder(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
|
||||
* maxfev,diag,mode,factor,nprint,info,nfev,njev,
|
||||
* ipvt,qtf,wa1,wa2,wa3,wa4)
|
||||
integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev
|
||||
diff --git a/scipy/optimize/minpack/lmder1.f b/scipy/optimize/minpack/lmder1.f
|
||||
index 6be29477d..d691940fd 100644
|
||||
--- a/scipy/optimize/minpack/lmder1.f
|
||||
+++ b/scipy/optimize/minpack/lmder1.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,
|
||||
+ subroutine lmder1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,
|
||||
* lwa)
|
||||
integer m,n,ldfjac,info,lwa
|
||||
integer ipvt(n)
|
||||
diff --git a/scipy/optimize/minpack/lmdif.f b/scipy/optimize/minpack/lmdif.f
|
||||
index fcb61d138..dd3d4ee25 100644
|
||||
--- a/scipy/optimize/minpack/lmdif.f
|
||||
+++ b/scipy/optimize/minpack/lmdif.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,
|
||||
+ subroutine lmdif(fcn,m,n,x,fvec,ftol,xtol,gtol,maxfev,epsfcn,
|
||||
* diag,mode,factor,nprint,info,nfev,fjac,ldfjac,
|
||||
* ipvt,qtf,wa1,wa2,wa3,wa4)
|
||||
integer m,n,maxfev,mode,nprint,info,nfev,ldfjac
|
||||
diff --git a/scipy/optimize/minpack/lmdif1.f b/scipy/optimize/minpack/lmdif1.f
|
||||
index 6f28ed2f7..70f8aae05 100644
|
||||
--- a/scipy/optimize/minpack/lmdif1.f
|
||||
+++ b/scipy/optimize/minpack/lmdif1.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa)
|
||||
+ subroutine lmdif1(fcn,m,n,x,fvec,tol,info,iwa,wa,lwa)
|
||||
integer m,n,info,lwa
|
||||
integer iwa(n)
|
||||
double precision tol
|
||||
diff --git a/scipy/optimize/minpack/lmpar.f b/scipy/optimize/minpack/lmpar.f
|
||||
index e25eb0d3e..26c422a79 100644
|
||||
--- a/scipy/optimize/minpack/lmpar.f
|
||||
+++ b/scipy/optimize/minpack/lmpar.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1,
|
||||
+ subroutine lmpar(n,r,ldr,ipvt,diag,qtb,delta,par,x,sdiag,wa1,
|
||||
* wa2)
|
||||
integer n,ldr
|
||||
integer ipvt(n)
|
||||
diff --git a/scipy/optimize/minpack/lmstr.f b/scipy/optimize/minpack/lmstr.f
|
||||
index 2b6bbbfc2..d9a7893f8 100644
|
||||
--- a/scipy/optimize/minpack/lmstr.f
|
||||
+++ b/scipy/optimize/minpack/lmstr.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
|
||||
+ subroutine lmstr(fcn,m,n,x,fvec,fjac,ldfjac,ftol,xtol,gtol,
|
||||
* maxfev,diag,mode,factor,nprint,info,nfev,njev,
|
||||
* ipvt,qtf,wa1,wa2,wa3,wa4)
|
||||
integer m,n,ldfjac,maxfev,mode,nprint,info,nfev,njev
|
||||
diff --git a/scipy/optimize/minpack/lmstr1.f b/scipy/optimize/minpack/lmstr1.f
|
||||
index 225e8736f..2fa8ee1c5 100644
|
||||
--- a/scipy/optimize/minpack/lmstr1.f
|
||||
+++ b/scipy/optimize/minpack/lmstr1.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,
|
||||
+ subroutine lmstr1(fcn,m,n,x,fvec,fjac,ldfjac,tol,info,ipvt,wa,
|
||||
* lwa)
|
||||
integer m,n,ldfjac,info,lwa
|
||||
integer ipvt(n)
|
||||
diff --git a/scipy/optimize/minpack/qform.f b/scipy/optimize/minpack/qform.f
|
||||
index 1f368587e..087b2478b 100644
|
||||
--- a/scipy/optimize/minpack/qform.f
|
||||
+++ b/scipy/optimize/minpack/qform.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine qform(m,n,q,ldq,wa)
|
||||
+ subroutine qform(m,n,q,ldq,wa)
|
||||
integer m,n,ldq
|
||||
double precision q(ldq,m),wa(m)
|
||||
c **********
|
||||
diff --git a/scipy/optimize/minpack/qrfac.f b/scipy/optimize/minpack/qrfac.f
|
||||
index fa6789086..cb686086c 100644
|
||||
--- a/scipy/optimize/minpack/qrfac.f
|
||||
+++ b/scipy/optimize/minpack/qrfac.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa)
|
||||
+ subroutine qrfac(m,n,a,lda,pivot,ipvt,lipvt,rdiag,acnorm,wa)
|
||||
integer m,n,lda,lipvt
|
||||
integer ipvt(lipvt)
|
||||
logical pivot
|
||||
diff --git a/scipy/optimize/minpack/qrsolv.f b/scipy/optimize/minpack/qrsolv.f
|
||||
index 3dc009721..5580087ca 100644
|
||||
--- a/scipy/optimize/minpack/qrsolv.f
|
||||
+++ b/scipy/optimize/minpack/qrsolv.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa)
|
||||
+ subroutine qrsolv(n,r,ldr,ipvt,diag,qtb,x,sdiag,wa)
|
||||
integer n,ldr
|
||||
integer ipvt(n)
|
||||
double precision r(ldr,n),diag(n),qtb(n),x(n),sdiag(n),wa(n)
|
||||
diff --git a/scipy/optimize/minpack/r1mpyq.f b/scipy/optimize/minpack/r1mpyq.f
|
||||
index 1410b9ad6..ec99b96ce 100644
|
||||
--- a/scipy/optimize/minpack/r1mpyq.f
|
||||
+++ b/scipy/optimize/minpack/r1mpyq.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine r1mpyq(m,n,a,lda,v,w)
|
||||
+ subroutine r1mpyq(m,n,a,lda,v,w)
|
||||
integer m,n,lda
|
||||
double precision a(lda,n),v(n),w(n)
|
||||
c **********
|
||||
diff --git a/scipy/optimize/minpack/r1updt.f b/scipy/optimize/minpack/r1updt.f
|
||||
index e809d8402..e034973d9 100644
|
||||
--- a/scipy/optimize/minpack/r1updt.f
|
||||
+++ b/scipy/optimize/minpack/r1updt.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine r1updt(m,n,s,ls,u,v,w,sing)
|
||||
+ subroutine r1updt(m,n,s,ls,u,v,w,sing)
|
||||
integer m,n,ls
|
||||
logical sing
|
||||
double precision s(ls),u(m),v(n),w(m)
|
||||
diff --git a/scipy/optimize/minpack/rwupdt.f b/scipy/optimize/minpack/rwupdt.f
|
||||
index 61a7928bb..05282b556 100644
|
||||
--- a/scipy/optimize/minpack/rwupdt.f
|
||||
+++ b/scipy/optimize/minpack/rwupdt.f
|
||||
@@ -1,5 +1,4 @@
|
||||
- recursive
|
||||
- *subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin)
|
||||
+ subroutine rwupdt(n,r,ldr,w,b,alpha,cos,sin)
|
||||
integer n,ldr
|
||||
double precision alpha
|
||||
double precision r(ldr,n),w(n),b(n),cos(n),sin(n)
|
|
@ -0,0 +1,317 @@
|
|||
We are hijacking dfft.f to inject missing functions from future versions of LAPACK.
|
||||
|
||||
This patch is applied to the generated dfft.c after f2c is applied to dfft.f.
|
||||
This must be done in between when f2c is applied to dfft.f and when dfft.c is compiled.
|
||||
This is arranged in _f2c_fixes.py.
|
||||
|
||||
f2c does not correctly handle implicit casts of function arguments. If the implicit casts
|
||||
are between integer types then we can handle that automatically in _f2c_fixes.py. This
|
||||
patch fixes implicit casts from char* to int, which we need to deal with manually.
|
||||
|
||||
--- a/scipy/linalg/src/id_dist/src/dfft.c
|
||||
+++ b/scipy/linalg/src/id_dist/src/dfft.c
|
||||
@@ -2855,8 +2855,7 @@ f_rook.f"> */
|
||||
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), ctprfb_(
|
||||
char *, char *, char *, char *, integer *, integer *, integer *,
|
||||
integer *, complex *, integer *, complex *, integer *, complex *,
|
||||
- integer *, complex *, integer *, complex *, integer *, ftnlen,
|
||||
- ftnlen, ftnlen, ftnlen);
|
||||
+ integer *, complex *, integer *, complex *, integer *);
|
||||
static logical notran;
|
||||
|
||||
|
||||
@@ -2967,8 +2966,7 @@ f_rook.f"> */
|
||||
}
|
||||
ctprfb_("L", "C", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && notran) {
|
||||
@@ -2989,8 +2987,7 @@ f_rook.f"> */
|
||||
}
|
||||
ctprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
} else if (left && notran) {
|
||||
@@ -3011,8 +3008,7 @@ f_rook.f"> */
|
||||
}
|
||||
ctprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && tran) {
|
||||
@@ -3033,8 +3029,7 @@ f_rook.f"> */
|
||||
}
|
||||
ctprfb_("R", "C", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3247,8 +3242,7 @@ f"> */
|
||||
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), ctprfb_(
|
||||
char *, char *, char *, char *, integer *, integer *, integer *,
|
||||
integer *, complex *, integer *, complex *, integer *, complex *,
|
||||
- integer *, complex *, integer *, complex *, integer *, ftnlen,
|
||||
- ftnlen, ftnlen, ftnlen), ctpqrt2_(integer *, integer *, integer *,
|
||||
+ integer *, complex *, integer *, complex *, integer *), ctpqrt2_(integer *, integer *, integer *,
|
||||
complex *, integer *, complex *, integer *, complex *, integer *,
|
||||
integer *);
|
||||
|
||||
@@ -3342,7 +3336,7 @@ f"> */
|
||||
ctprfb_("L", "C", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1
|
||||
+ 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib)
|
||||
* a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1]
|
||||
- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1);
|
||||
+ , &ib);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -6041,11 +6035,13 @@ f_rook.f"> */
|
||||
static integer ldvq;
|
||||
extern logical lsame_(char *, char *, ftnlen, ftnlen);
|
||||
static logical right;
|
||||
- extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), dtprfb_(
|
||||
+ extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen),
|
||||
+
|
||||
+ dtprfb_(
|
||||
char *, char *, char *, char *, integer *, integer *, integer *,
|
||||
integer *, doublereal *, integer *, doublereal *, integer *,
|
||||
doublereal *, integer *, doublereal *, integer *, doublereal *,
|
||||
- integer *, ftnlen, ftnlen, ftnlen, ftnlen);
|
||||
+ integer *);
|
||||
static logical notran;
|
||||
|
||||
|
||||
@@ -6156,8 +6152,7 @@ f_rook.f"> */
|
||||
}
|
||||
dtprfb_("L", "T", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && notran) {
|
||||
@@ -6178,8 +6173,7 @@ f_rook.f"> */
|
||||
}
|
||||
dtprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
} else if (left && notran) {
|
||||
@@ -6200,8 +6194,7 @@ f_rook.f"> */
|
||||
}
|
||||
dtprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && tran) {
|
||||
@@ -6222,8 +6215,7 @@ f_rook.f"> */
|
||||
}
|
||||
dtprfb_("R", "T", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6433,13 +6425,12 @@ f"> */
|
||||
|
||||
/* Local variables */
|
||||
static integer i__, ib, lb, mb, iinfo;
|
||||
- extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), dtprfb_(
|
||||
- char *, char *, char *, char *, integer *, integer *, integer *,
|
||||
- integer *, doublereal *, integer *, doublereal *, integer *,
|
||||
- doublereal *, integer *, doublereal *, integer *, doublereal *,
|
||||
- integer *, ftnlen, ftnlen, ftnlen, ftnlen), dtpqrt2_(integer *,
|
||||
- integer *, integer *, doublereal *, integer *, doublereal *,
|
||||
- integer *, doublereal *, integer *, integer *);
|
||||
+ extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen),
|
||||
+
|
||||
+dtprfb_(char *, char *, char *, char *, integer *, integer *, integer *, integer *, doublereal *, integer *, doublereal *, integer *,
|
||||
+ doublereal *, integer *, doublereal *, integer *, doublereal *, integer *),
|
||||
+
|
||||
+ dtpqrt2_(integer *, integer *, integer *, doublereal *, integer *, doublereal *, integer *, doublereal *, integer *, integer *);
|
||||
|
||||
|
||||
/* -- LAPACK computational routine -- */
|
||||
@@ -6531,9 +6522,8 @@ f"> */
|
||||
dtprfb_("L", "T", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1
|
||||
+ 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib)
|
||||
* a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1]
|
||||
- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1);
|
||||
- }
|
||||
- }
|
||||
+ , &ib);
|
||||
+ }}
|
||||
return 0;
|
||||
|
||||
/* End of DTPQRT */
|
||||
@@ -9226,8 +9216,7 @@ f_rook.f"> */
|
||||
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), stprfb_(
|
||||
char *, char *, char *, char *, integer *, integer *, integer *,
|
||||
integer *, real *, integer *, real *, integer *, real *, integer *
|
||||
- , real *, integer *, real *, integer *, ftnlen, ftnlen, ftnlen,
|
||||
- ftnlen);
|
||||
+ , real *, integer *, real *, integer *);
|
||||
static logical notran;
|
||||
|
||||
|
||||
@@ -9338,8 +9327,7 @@ f_rook.f"> */
|
||||
}
|
||||
stprfb_("L", "T", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && notran) {
|
||||
@@ -9360,8 +9348,7 @@ f_rook.f"> */
|
||||
}
|
||||
stprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
} else if (left && notran) {
|
||||
@@ -9382,8 +9369,7 @@ f_rook.f"> */
|
||||
}
|
||||
stprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && tran) {
|
||||
@@ -9404,8 +9390,7 @@ f_rook.f"> */
|
||||
}
|
||||
stprfb_("R", "T", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9618,8 +9603,7 @@ f"> */
|
||||
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), stprfb_(
|
||||
char *, char *, char *, char *, integer *, integer *, integer *,
|
||||
integer *, real *, integer *, real *, integer *, real *, integer *
|
||||
- , real *, integer *, real *, integer *, ftnlen, ftnlen, ftnlen,
|
||||
- ftnlen), stpqrt2_(integer *, integer *, integer *, real *,
|
||||
+ , real *, integer *, real *, integer *), stpqrt2_(integer *, integer *, integer *, real *,
|
||||
integer *, real *, integer *, real *, integer *, integer *);
|
||||
|
||||
|
||||
@@ -9712,7 +9696,7 @@ f"> */
|
||||
stprfb_("L", "T", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1
|
||||
+ 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib)
|
||||
* a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1]
|
||||
- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1);
|
||||
+ , &ib);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -12502,8 +12486,7 @@ f_rook.f"> */
|
||||
extern /* Subroutine */ int ztprfb_(char *, char *, char *, char *,
|
||||
integer *, integer *, integer *, integer *, doublecomplex *,
|
||||
integer *, doublecomplex *, integer *, doublecomplex *, integer *,
|
||||
- doublecomplex *, integer *, doublecomplex *, integer *, ftnlen,
|
||||
- ftnlen, ftnlen, ftnlen);
|
||||
+ doublecomplex *, integer *, doublecomplex *, integer *);
|
||||
|
||||
|
||||
/* -- LAPACK computational routine -- */
|
||||
@@ -12613,8 +12596,7 @@ f_rook.f"> */
|
||||
}
|
||||
ztprfb_("L", "C", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && notran) {
|
||||
@@ -12635,8 +12617,7 @@ f_rook.f"> */
|
||||
}
|
||||
ztprfb_("R", "N", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
} else if (left && notran) {
|
||||
@@ -12657,8 +12638,7 @@ f_rook.f"> */
|
||||
}
|
||||
ztprfb_("L", "N", "F", "C", &mb, n, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ + a_dim1], lda, &
|
||||
- b[b_offset], ldb, &work[1], &ib, (ftnlen)1, (ftnlen)1, (
|
||||
- ftnlen)1, (ftnlen)1);
|
||||
+ b[b_offset], ldb, &work[1], &ib);
|
||||
}
|
||||
|
||||
} else if (right && tran) {
|
||||
@@ -12679,8 +12659,7 @@ f_rook.f"> */
|
||||
}
|
||||
ztprfb_("R", "C", "F", "C", m, &mb, &ib, &lb, &v[i__ * v_dim1 + 1]
|
||||
, ldv, &t[i__ * t_dim1 + 1], ldt, &a[i__ * a_dim1 + 1],
|
||||
- lda, &b[b_offset], ldb, &work[1], m, (ftnlen)1, (ftnlen)1,
|
||||
- (ftnlen)1, (ftnlen)1);
|
||||
+ lda, &b[b_offset], ldb, &work[1], m);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12894,7 +12873,7 @@ f"> */
|
||||
char *, char *, char *, char *, integer *, integer *, integer *,
|
||||
integer *, doublecomplex *, integer *, doublecomplex *, integer *,
|
||||
doublecomplex *, integer *, doublecomplex *, integer *,
|
||||
- doublecomplex *, integer *, ftnlen, ftnlen, ftnlen, ftnlen),
|
||||
+ doublecomplex *, integer *),
|
||||
ztpqrt2_(integer *, integer *, integer *, doublecomplex *,
|
||||
integer *, doublecomplex *, integer *, doublecomplex *, integer *,
|
||||
integer *);
|
||||
@@ -12989,7 +12968,7 @@ f"> */
|
||||
ztprfb_("L", "C", "F", "C", &mb, &i__3, &ib, &lb, &b[i__ * b_dim1
|
||||
+ 1], ldb, &t[i__ * t_dim1 + 1], ldt, &a[i__ + (i__ + ib)
|
||||
* a_dim1], lda, &b[(i__ + ib) * b_dim1 + 1], ldb, &work[1]
|
||||
- , &ib, (ftnlen)1, (ftnlen)1, (ftnlen)1, (ftnlen)1);
|
||||
+ , &ib);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -12998,3 +12977,10 @@ f"> */
|
||||
|
||||
} /* ztpqrt_ */
|
||||
|
||||
+
|
||||
+typedef struct { float real, imag; } npy_complex64;
|
||||
+typedef struct { double real, imag; } npy_complex128;
|
||||
+int sorcsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, float *x11, int *ldx11, float *x12, int *ldx12, float *x21, int *ldx21, float *x22, int *ldx22, float *theta, float *u1, int *ldu1, float *u2, int *ldu2, float *v1t, int *ldv1t, float *v2t, int *ldv2t, float *work, int *lwork, int *iwork, int *info){ return 0; }
|
||||
+int dorcsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, double *x11, int *ldx11, double *x12, int *ldx12, double *x21, int *ldx21, double *x22, int *ldx22, double *theta, double *u1, int *ldu1, double *u2, int *ldu2, double *v1t, int *ldv1t, double *v2t, int *ldv2t, double *work, int *lwork, int *iwork, int *info){ return 0; }
|
||||
+int zuncsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, npy_complex128 *x11, int *ldx11, npy_complex128 *x12, int *ldx12, npy_complex128 *x21, int *ldx21, npy_complex128 *x22, int *ldx22, double *theta, npy_complex128 *u1, int *ldu1, npy_complex128 *u2, int *ldu2, npy_complex128 *v1t, int *ldv1t, npy_complex128 *v2t, int *ldv2t, npy_complex128 *work, int *lwork, double *rwork, int *lrwork, int *iwork, int *info){ return 0; }
|
||||
+int cuncsd_(char *jobu1, char *jobu2, char *jobv1t, char *jobv2t, char *trans, char *signs, int *m, int *p, int *q, npy_complex64 *x11, int *ldx11, npy_complex64 *x12, int *ldx12, npy_complex64 *x21, int *ldx21, npy_complex64 *x22, int *ldx22, float *theta, npy_complex64 *u1, int *ldu1, npy_complex64 *u2, int *ldu2, npy_complex64 *v1t, int *ldv1t, npy_complex64 *v2t, int *ldv2t, npy_complex64 *work, int *lwork, float *rwork, int *lrwork, int *iwork, int *info){ return 0; }
|
|
@ -1,20 +0,0 @@
|
|||
commit 768251cd14ccbf467a8725e5476e35fb2735ee4a
|
||||
Author: Warren Weckesser <warren.weckesser@gmail.com>
|
||||
Date: Fri Mar 9 00:32:22 2018 -0500
|
||||
|
||||
BUG: linalg: Fixed typo in flapack.pyf.src.
|
||||
Available in scipy 1.0.1 (https://github.com/scipy/scipy/pull/8530)
|
||||
|
||||
diff --git a/scipy/linalg/flapack.pyf.src b/scipy/linalg/flapack.pyf.src
|
||||
index e6c8c1840..54cf7c4b1 100644
|
||||
--- a/scipy/linalg/flapack.pyf.src
|
||||
+++ b/scipy/linalg/flapack.pyf.src
|
||||
@@ -1748,7 +1748,7 @@ end subroutine <prefix>gels_lwork
|
||||
callprotoargument int*,int*,int*,<ctype2c>*,int*,<ctype2c>*,int*,int*,<ctype2>*,int*,<ctype2c>*,int*,<ctype2>*,int*
|
||||
|
||||
integer intent(in) :: m
|
||||
- integer intent(in)):: n
|
||||
+ integer intent(in) :: n
|
||||
integer intent(hide) :: maxmn = MAX(m,n)
|
||||
<ftype2c> intent(hide) :: a
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
commit 7a5b003922134abd01ae33b0a3e84d006673e9c6
|
||||
Author: Roman Yurchak <rth.yurchak@pm.me>
|
||||
Date: Mon Oct 8 12:13:55 2018 +0200
|
||||
|
||||
Workaround for malloc issues
|
||||
|
||||
This aims to avoid the "invalid call target: $_malloc" issues
|
||||
|
||||
- fixes scipy/optimize/zeros.c
|
||||
- skips scipy/integrate/dop.pyf
|
||||
- skips scipy/optimize/cobyla
|
||||
|
||||
diff --git a/scipy/integrate/setup.py b/scipy/integrate/setup.py
|
||||
index 2be454c70..0545dc759 100755
|
||||
--- a/scipy/integrate/setup.py
|
||||
+++ b/scipy/integrate/setup.py
|
||||
@@ -67,10 +67,10 @@ def configuration(parent_package='',top_path=None):
|
||||
# **lapack_opt)
|
||||
|
||||
# dop
|
||||
- config.add_extension('_dop',
|
||||
- sources=['dop.pyf'],
|
||||
- libraries=['dop'],
|
||||
- depends=dop_src)
|
||||
+ #config.add_extension('_dop',
|
||||
+ # sources=['dop.pyf'],
|
||||
+ # libraries=['dop'],
|
||||
+ # depends=dop_src)
|
||||
|
||||
config.add_extension('_test_multivariate',
|
||||
sources=quadpack_test_src)
|
||||
diff --git a/scipy/optimize/__init__.py b/scipy/optimize/__init__.py
|
||||
index 17ba78371..5deca7498 100644
|
||||
--- a/scipy/optimize/__init__.py
|
||||
+++ b/scipy/optimize/__init__.py
|
||||
@@ -236,7 +236,7 @@ from .minpack import *
|
||||
from .zeros import *
|
||||
from .lbfgsb import fmin_l_bfgs_b, LbfgsInvHessProduct
|
||||
from .tnc import fmin_tnc
|
||||
-from .cobyla import fmin_cobyla
|
||||
+#from .cobyla import fmin_cobyla
|
||||
from .nonlin import *
|
||||
from .slsqp import fmin_slsqp
|
||||
from .nnls import nnls
|
||||
diff --git a/scipy/optimize/_minimize.py b/scipy/optimize/_minimize.py
|
||||
index 259546035..8b0b6960b 100644
|
||||
--- a/scipy/optimize/_minimize.py
|
||||
+++ b/scipy/optimize/_minimize.py
|
||||
@@ -29,7 +29,8 @@ from ._trustregion_ncg import _minimize_trust_ncg
|
||||
# constrained minimization
|
||||
from .lbfgsb import _minimize_lbfgsb
|
||||
from .tnc import _minimize_tnc
|
||||
-from .cobyla import _minimize_cobyla
|
||||
+#from .cobyla import _minimize_cobyla
|
||||
+_minimize_cobyla = None
|
||||
from .slsqp import _minimize_slsqp
|
||||
|
||||
|
||||
diff --git a/scipy/optimize/setup.py b/scipy/optimize/setup.py
|
||||
index 7d2b987cb..1861e7563 100755
|
||||
--- a/scipy/optimize/setup.py
|
||||
+++ b/scipy/optimize/setup.py
|
||||
@@ -50,11 +50,11 @@ def configuration(parent_package='',top_path=None):
|
||||
depends=[join('tnc','tnc.h')],
|
||||
**numpy_nodepr_api)
|
||||
|
||||
- config.add_extension('_cobyla',
|
||||
- sources=[join('cobyla',x) for x in ['cobyla.pyf',
|
||||
- 'cobyla2.f',
|
||||
- 'trstlp.f']],
|
||||
- **numpy_nodepr_api)
|
||||
+ #config.add_extension('_cobyla',
|
||||
+ # sources=[join('cobyla',x) for x in ['cobyla.pyf',
|
||||
+ # 'cobyla2.f',
|
||||
+ # 'trstlp.f']],
|
||||
+ # **numpy_nodepr_api)
|
||||
|
||||
sources = ['minpack2.pyf', 'dcsrch.f', 'dcstep.f']
|
||||
config.add_extension('minpack2',
|
||||
diff --git a/scipy/optimize/zeros.c b/scipy/optimize/zeros.c
|
||||
index e557f37cb..d450b3ed4 100644
|
||||
--- a/scipy/optimize/zeros.c
|
||||
+++ b/scipy/optimize/zeros.c
|
||||
@@ -193,6 +193,10 @@ PyObject *PyInit__zeros(void)
|
||||
{
|
||||
PyObject *m;
|
||||
|
||||
+ volatile long x;
|
||||
+ x = (long)malloc(0);
|
||||
+ free((void*)x);
|
||||
+
|
||||
m = PyModule_Create(&moduledef);
|
||||
|
||||
return m;
|
|
@ -0,0 +1,87 @@
|
|||
From 549ab1f7916e16222bdfc67a46f7a7b9b2125265 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sat, 18 Dec 2021 11:41:15 -0800
|
||||
Subject: [PATCH] gemm_ no const
|
||||
|
||||
cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but
|
||||
other places don't have the cosnt causing compile errors.
|
||||
This patch drops the consts and fixes the problem.
|
||||
|
||||
---
|
||||
scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h | 6 +++---
|
||||
scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h | 6 +++---
|
||||
scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h | 6 +++---
|
||||
scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h | 6 +++---
|
||||
4 files changed, 12 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
|
||||
index 346f9af0a..8af19888f 100644
|
||||
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
|
||||
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
|
||||
@@ -272,9 +272,9 @@ extern void ccheck_tempv(int, complex *);
|
||||
|
||||
/*! \brief BLAS */
|
||||
|
||||
-extern int cgemm_(const char*, const char*, const int*, const int*, const int*,
|
||||
- const complex*, const complex*, const int*, const complex*,
|
||||
- const int*, const complex*, complex*, const int*);
|
||||
+extern int cgemm_( char*, char*, int*, int*, int*,
|
||||
+ complex*, complex*, int*, complex*,
|
||||
+ int*, complex*, complex*, int*);
|
||||
extern int ctrsv_(char*, char*, char*, int*, complex*, int*,
|
||||
complex*, int*);
|
||||
extern int ctrsm_(char*, char*, char*, char*, int*, int*,
|
||||
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
|
||||
index 934cd677a..33e869fb7 100644
|
||||
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
|
||||
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
|
||||
@@ -269,9 +269,9 @@ extern void dcheck_tempv(int, double *);
|
||||
|
||||
/*! \brief BLAS */
|
||||
|
||||
-extern int dgemm_(const char*, const char*, const int*, const int*, const int*,
|
||||
- const double*, const double*, const int*, const double*,
|
||||
- const int*, const double*, double*, const int*);
|
||||
+extern int dgemm_( char*, char*, int*, int*, int*,
|
||||
+ double*, double*, int*, double*,
|
||||
+ int*, double*, double*, int*);
|
||||
extern int dtrsv_(char*, char*, char*, int*, double*, int*,
|
||||
double*, int*);
|
||||
extern int dtrsm_(char*, char*, char*, char*, int*, int*,
|
||||
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
|
||||
index 1b6db977e..fee4bc1d6 100644
|
||||
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
|
||||
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
|
||||
@@ -269,9 +269,9 @@ extern void scheck_tempv(int, float *);
|
||||
|
||||
/*! \brief BLAS */
|
||||
|
||||
-extern int sgemm_(const char*, const char*, const int*, const int*, const int*,
|
||||
- const float*, const float*, const int*, const float*,
|
||||
- const int*, const float*, float*, const int*);
|
||||
+extern int sgemm_( char*, char*, int*, int*, int*,
|
||||
+ float*, float*, int*, float*,
|
||||
+ int*, float*, float*, int*);
|
||||
extern int strsv_(char*, char*, char*, int*, float*, int*,
|
||||
float*, int*);
|
||||
extern int strsm_(char*, char*, char*, char*, int*, int*,
|
||||
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
|
||||
index abb7d937e..6c572ff2b 100644
|
||||
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
|
||||
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
|
||||
@@ -272,9 +272,9 @@ extern void zcheck_tempv(int, doublecomplex *);
|
||||
|
||||
/*! \brief BLAS */
|
||||
|
||||
-extern int zgemm_(const char*, const char*, const int*, const int*, const int*,
|
||||
- const doublecomplex*, const doublecomplex*, const int*, const doublecomplex*,
|
||||
- const int*, const doublecomplex*, doublecomplex*, const int*);
|
||||
+extern int zgemm_( char*, char*, int*, int*, int*,
|
||||
+ doublecomplex*, doublecomplex*, int*, doublecomplex*,
|
||||
+ int*, doublecomplex*, doublecomplex*, int*);
|
||||
extern int ztrsv_(char*, char*, char*, int*, doublecomplex*, int*,
|
||||
doublecomplex*, int*);
|
||||
extern int ztrsm_(char*, char*, char*, char*, int*, int*,
|
||||
--
|
||||
2.25.1
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,35 @@
|
|||
From 7b56e1341c486422973dfa890158872200527b51 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sat, 25 Dec 2021 20:31:40 -0800
|
||||
Subject: [PATCH] Remove cuncsd, dorcsd, sorcsd, zuncsd
|
||||
|
||||
These functions don't work because their definitions involve code that isn't
|
||||
fortran 77 compliant. In order to get _flapack.so to link correctly, we need
|
||||
to provide stub definitions for these functions, but they don't work. Remove
|
||||
them to make sure people get an `AttributeError` if they try to use them
|
||||
rather than just having weird buggy code.
|
||||
|
||||
---
|
||||
scipy/linalg/__init__.py | 6 ++++++
|
||||
1 file changed, 6 insertions(+)
|
||||
|
||||
diff --git a/scipy/linalg/__init__.py b/scipy/linalg/__init__.py
|
||||
index e88479b48..746bf3dce 100644
|
||||
--- a/scipy/linalg/__init__.py
|
||||
+++ b/scipy/linalg/__init__.py
|
||||
@@ -191,6 +191,12 @@ Low-level routines
|
||||
`scipy.linalg.cython_lapack` -- Low-level LAPACK functions for Cython
|
||||
|
||||
""" # noqa: E501
|
||||
+from . import lapack
|
||||
+del lapack.cuncsd
|
||||
+del lapack.dorcsd
|
||||
+del lapack.sorcsd
|
||||
+del lapack.zuncsd
|
||||
+del lapack
|
||||
|
||||
from .misc import *
|
||||
from .basic import *
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,199 @@
|
|||
From 8e62ac7ee97e6046745ba086545ac9c2511279f8 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sat, 25 Dec 2021 16:02:23 -0800
|
||||
Subject: [PATCH] remove mvnun -- not fortran 77 compliant
|
||||
|
||||
These two functions use features from newer fortran standards which won't work
|
||||
with f2c. This deletes them.
|
||||
|
||||
---
|
||||
scipy/stats/mvn.pyf | 29 ----------
|
||||
scipy/stats/mvndst.f | 132 -------------------------------------------
|
||||
2 files changed, 161 deletions(-)
|
||||
|
||||
diff --git a/scipy/stats/mvn.pyf b/scipy/stats/mvn.pyf
|
||||
index c9022b8de..cb0862a76 100644
|
||||
--- a/scipy/stats/mvn.pyf
|
||||
+++ b/scipy/stats/mvn.pyf
|
||||
@@ -3,35 +3,6 @@
|
||||
|
||||
python module mvn ! in
|
||||
interface ! in :mvn
|
||||
- subroutine mvnun(d,n,lower,upper,means,covar,maxpts,abseps,releps,value,inform) ! in :mvn:mvndst.f
|
||||
- integer intent(hide) :: d=shape(means,0)
|
||||
- integer intent(hide) :: n=shape(means,1)
|
||||
- double precision dimension(d) :: lower
|
||||
- double precision dimension(d) :: upper
|
||||
- double precision dimension(d,n) :: means
|
||||
- double precision dimension(d,d) :: covar
|
||||
- integer intent(optional) :: maxpts=d*1000
|
||||
- double precision intent(optional) :: abseps=1e-6
|
||||
- double precision intent(optional) :: releps=1e-6
|
||||
- double precision intent(out) :: value
|
||||
- integer intent(out) :: inform
|
||||
- end subroutine mvnun
|
||||
-
|
||||
- subroutine mvnun_weighted(d,n,lower,upper,means,weights,covar,maxpts,abseps,releps,value,inform) ! in :mvn:mvndst.f
|
||||
- integer intent(hide) :: d=shape(means,0)
|
||||
- integer intent(hide) :: n=shape(means,1)
|
||||
- double precision dimension(d) :: lower
|
||||
- double precision dimension(d) :: upper
|
||||
- double precision dimension(d,n) :: means
|
||||
- double precision dimension(n) :: weights
|
||||
- double precision dimension(d,d) :: covar
|
||||
- integer intent(optional) :: maxpts=d*1000
|
||||
- double precision intent(optional) :: abseps=1e-6
|
||||
- double precision intent(optional) :: releps=1e-6
|
||||
- double precision intent(out) :: value
|
||||
- integer intent(out) :: inform
|
||||
- end subroutine mvnun_weighted
|
||||
-
|
||||
subroutine mvndst(n,lower,upper,infin,correl,maxpts,abseps,releps,error,value,inform) ! in :mvn:mvndst.f
|
||||
integer intent(hide) :: n=len(lower)
|
||||
double precision dimension(n) :: lower
|
||||
diff --git a/scipy/stats/mvndst.f b/scipy/stats/mvndst.f
|
||||
index 41afa7e74..76d9690e3 100644
|
||||
--- a/scipy/stats/mvndst.f
|
||||
+++ b/scipy/stats/mvndst.f
|
||||
@@ -21,138 +21,6 @@
|
||||
* Pullman, WA 99164-3113
|
||||
* Email : alangenz@wsu.edu
|
||||
*
|
||||
- SUBROUTINE mvnun(d, n, lower, upper, means, covar, maxpts,
|
||||
- & abseps, releps, value, inform)
|
||||
-* Parameters
|
||||
-*
|
||||
-* d integer, dimensionality of the data
|
||||
-* n integer, the number of data points
|
||||
-* lower double(2), the lower integration limits
|
||||
-* upper double(2), the upper integration limits
|
||||
-* means double(n), the mean of each kernel
|
||||
-* covar double(2,2), the covariance matrix
|
||||
-* maxpts integer, the maximum number of points to evaluate at
|
||||
-* abseps double, absolute error tolerance
|
||||
-* releps double, relative error tolerance
|
||||
-* value double intent(out), integral value
|
||||
-* inform integer intent(out),
|
||||
-* if inform == 0: error < eps
|
||||
-* elif inform == 1: error > eps, all maxpts used
|
||||
- integer n, d, infin(d), maxpts, inform, tmpinf
|
||||
- double precision lower(d), upper(d), releps, abseps,
|
||||
- & error, value, stdev(d), rho(d*(d-1)/2),
|
||||
- & covar(d,d),
|
||||
- & nlower(d), nupper(d), means(d,n), tmpval,
|
||||
- & inf
|
||||
- integer i, j
|
||||
-
|
||||
- inf = 0d0
|
||||
- inf = 1d0 / inf
|
||||
-
|
||||
- do i=1,d
|
||||
- stdev(i) = dsqrt(covar(i,i))
|
||||
- if (upper(i).eq.inf.and.lower(i).eq.-inf) then
|
||||
- infin(i) = -1
|
||||
- else if (lower(i).eq.-inf) then
|
||||
- infin(i) = 0
|
||||
- else if (upper(i).eq.inf) then
|
||||
- infin(i) = 1
|
||||
- else
|
||||
- infin(i) = 2
|
||||
- end if
|
||||
- end do
|
||||
- do i=1,d
|
||||
- do j=1,i-1
|
||||
- rho(j+(i-2)*(i-1)/2) = covar(i,j)/stdev(i)/stdev(j)
|
||||
- end do
|
||||
- end do
|
||||
- value = 0d0
|
||||
-
|
||||
- inform = 0
|
||||
-
|
||||
- do i=1,n
|
||||
- do j=1,d
|
||||
- nlower(j) = (lower(j) - means(j,i))/stdev(j)
|
||||
- nupper(j) = (upper(j) - means(j,i))/stdev(j)
|
||||
- end do
|
||||
- call mvndst(d,nlower,nupper,infin,rho,maxpts,abseps,releps,
|
||||
- & error,tmpval,tmpinf)
|
||||
- value = value + tmpval
|
||||
- if (tmpinf .eq. 1) then
|
||||
- inform = 1
|
||||
- end if
|
||||
- end do
|
||||
-
|
||||
- value = value / n
|
||||
-
|
||||
- END
|
||||
-
|
||||
-
|
||||
- SUBROUTINE mvnun_weighted(d, n, lower, upper, means, weights,
|
||||
- & covar, maxpts, abseps, releps,
|
||||
- & value, inform)
|
||||
-* Parameters
|
||||
-*
|
||||
-* d integer, dimensionality of the data
|
||||
-* n integer, the number of data points
|
||||
-* lower double(2), the lower integration limits
|
||||
-* upper double(2), the upper integration limits
|
||||
-* means double(n), the mean of each kernel
|
||||
-* weights double(n), the weight of each kernel
|
||||
-* covar double(2,2), the covariance matrix
|
||||
-* maxpts integer, the maximum number of points to evaluate at
|
||||
-* abseps double, absolute error tolerance
|
||||
-* releps double, relative error tolerance
|
||||
-* value double intent(out), integral value
|
||||
-* inform integer intent(out),
|
||||
-* if inform == 0: error < eps
|
||||
-* elif inform == 1: error > eps, all maxpts used
|
||||
- integer n, d, infin(d), maxpts, inform, tmpinf
|
||||
- double precision lower(d), upper(d), releps, abseps,
|
||||
- & error, value, stdev(d), rho(d*(d-1)/2),
|
||||
- & covar(d,d),
|
||||
- & nlower(d), nupper(d), means(d,n), tmpval,
|
||||
- & inf, weights(n)
|
||||
- integer i, j
|
||||
-
|
||||
- inf = 0d0
|
||||
- inf = 1d0 / inf
|
||||
-
|
||||
- do i=1,d
|
||||
- stdev(i) = dsqrt(covar(i,i))
|
||||
- if (upper(i).eq.inf.and.lower(i).eq.-inf) then
|
||||
- infin(i) = -1
|
||||
- else if (lower(i).eq.-inf) then
|
||||
- infin(i) = 0
|
||||
- else if (upper(i).eq.inf) then
|
||||
- infin(i) = 1
|
||||
- else
|
||||
- infin(i) = 2
|
||||
- end if
|
||||
- end do
|
||||
- do i=1,d
|
||||
- do j=1,i-1
|
||||
- rho(j+(i-2)*(i-1)/2) = covar(i,j)/stdev(i)/stdev(j)
|
||||
- end do
|
||||
- end do
|
||||
- value = 0d0
|
||||
-
|
||||
- inform = 0
|
||||
-
|
||||
- do i=1,n
|
||||
- do j=1,d
|
||||
- nlower(j) = (lower(j) - means(j,i))/stdev(j)
|
||||
- nupper(j) = (upper(j) - means(j,i))/stdev(j)
|
||||
- end do
|
||||
- call mvndst(d,nlower,nupper,infin,rho,maxpts,abseps,releps,
|
||||
- & error,tmpval,tmpinf)
|
||||
- value = value + tmpval * weights(i)
|
||||
- if (tmpinf .eq. 1) then
|
||||
- inform = 1
|
||||
- end if
|
||||
- end do
|
||||
-
|
||||
- END
|
||||
|
||||
SUBROUTINE MVNDST( N, LOWER, UPPER, INFIN, CORREL, MAXPTS,
|
||||
& ABSEPS, RELEPS, ERROR, VALUE, INFORM )
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
From 6ffb169dbe331627d70da3f79f928057f1a4e163 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sun, 26 Dec 2021 07:34:40 -0800
|
||||
Subject: [PATCH] Rename _page_trend_test.py to prevent test unvendoring
|
||||
|
||||
unvendor_tests will unvendor any file that ends in _test.py.
|
||||
Prevent that by changing the name of this file.
|
||||
|
||||
---
|
||||
scipy/stats/__init__.py | 2 +-
|
||||
scipy/stats/{_page_trend_test.py => _page_trend_test_.py} | 0
|
||||
2 files changed, 1 insertion(+), 1 deletion(-)
|
||||
rename scipy/stats/{_page_trend_test.py => _page_trend_test_.py} (100%)
|
||||
|
||||
diff --git a/scipy/stats/__init__.py b/scipy/stats/__init__.py
|
||||
index f410f5410..ad702c38d 100644
|
||||
--- a/scipy/stats/__init__.py
|
||||
+++ b/scipy/stats/__init__.py
|
||||
@@ -453,7 +453,7 @@ from ._bootstrap import bootstrap
|
||||
from ._entropy import *
|
||||
from ._hypotests import *
|
||||
from ._rvs_sampling import rvs_ratio_uniforms, NumericalInverseHermite
|
||||
-from ._page_trend_test import page_trend_test
|
||||
+from ._page_trend_test_ import page_trend_test
|
||||
from ._mannwhitneyu import mannwhitneyu
|
||||
|
||||
__all__ = [s for s in dir() if not s.startswith("_")] # Remove dunders.
|
||||
diff --git a/scipy/stats/_page_trend_test.py b/scipy/stats/_page_trend_test_.py
|
||||
similarity index 100%
|
||||
rename from scipy/stats/_page_trend_test.py
|
||||
rename to scipy/stats/_page_trend_test_.py
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
From 9fe7ab77cbc2227982f87c9dbb8aa675b98fe9a8 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sat, 18 Dec 2021 12:31:51 -0800
|
||||
Subject: [PATCH] sasum returns double not float
|
||||
|
||||
---
|
||||
scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c
|
||||
index 50efe7849..c176fddb4 100644
|
||||
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c
|
||||
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slacon2.c
|
||||
@@ -104,7 +104,7 @@ slacon2_(int *n, float *v, float *x, int *isgn, float *est, int *kase, int isave
|
||||
extern int SCOPY(int *, float *, int *, float *, int *);
|
||||
#else
|
||||
extern int isamax_(int *, float *, int *);
|
||||
- extern float sasum_(int *, float *, int *);
|
||||
+ extern double sasum_(int *, float *, int *);
|
||||
extern int scopy_(int *, float *, int *, float *, int *);
|
||||
#endif
|
||||
#define d_sign(a, b) (b >= 0 ? fabs(a) : -fabs(a)) /* Copy sign */
|
||||
--
|
||||
2.25.1
|
||||
|
|
@ -1,125 +1,47 @@
|
|||
commit c3affe05b5cb8d992cb7a955ff8b4c79452f3cc9
|
||||
Author: Roman Yurchak <rth.yurchak@pm.me>
|
||||
Date: Thu Oct 11 17:10:36 2018 +0200
|
||||
From ad5d7fb18134af51cd1d40599a0bf59a4782ec53 Mon Sep 17 00:00:00 2001
|
||||
From: Hood Chatham <roberthoodchatham@gmail.com>
|
||||
Date: Sat, 25 Dec 2021 15:08:18 -0800
|
||||
Subject: [PATCH] skip fortran fails to link
|
||||
|
||||
Skip fortran code that fails to link
|
||||
|
||||
scipy.integrate.odepack
|
||||
These are tests and they have both void vs int return value problems and implicit
|
||||
function argument cast problems. Not worth fixing for tests.
|
||||
|
||||
---
|
||||
scipy/integrate/setup.py | 6 ------
|
||||
scipy/io/setup.py | 3 ---
|
||||
2 files changed, 9 deletions(-)
|
||||
|
||||
diff --git a/scipy/integrate/_ode.py b/scipy/integrate/_ode.py
|
||||
index de1064048..52bf3875a 100644
|
||||
--- a/scipy/integrate/_ode.py
|
||||
+++ b/scipy/integrate/_ode.py
|
||||
@@ -89,10 +89,19 @@ import re
|
||||
import warnings
|
||||
|
||||
from numpy import asarray, array, zeros, int32, isscalar, real, imag, vstack
|
||||
-
|
||||
-from . import vode as _vode
|
||||
-from . import _dop
|
||||
-from . import lsoda as _lsoda
|
||||
+try:
|
||||
+ from . import vode as _vode
|
||||
+except ImportError:
|
||||
+ _vode = None
|
||||
+try:
|
||||
+ from . import _dop
|
||||
+except ImportError:
|
||||
+ _dop = None
|
||||
+
|
||||
+try:
|
||||
+ from . import lsoda as _lsoda
|
||||
+except ImportError:
|
||||
+ _lsoda = None
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
diff --git a/scipy/integrate/odepack.py b/scipy/integrate/odepack.py
|
||||
index eee2b04a3..17224f54e 100644
|
||||
--- a/scipy/integrate/odepack.py
|
||||
+++ b/scipy/integrate/odepack.py
|
||||
@@ -3,7 +3,8 @@ from __future__ import division, print_function, absolute_import
|
||||
|
||||
__all__ = ['odeint']
|
||||
|
||||
-from . import _odepack
|
||||
+# from . import _odepack
|
||||
+_odepack = None
|
||||
from copy import copy
|
||||
import warnings
|
||||
|
||||
diff --git a/scipy/integrate/setup.py b/scipy/integrate/setup.py
|
||||
index 4725eb1c0..0545dc759 100755
|
||||
index 11ce3d1aa..ddd7b08b2 100644
|
||||
--- a/scipy/integrate/setup.py
|
||||
+++ b/scipy/integrate/setup.py
|
||||
@@ -27,7 +27,7 @@ def configuration(parent_package='',top_path=None):
|
||||
config.add_library('mach', sources=mach_src,
|
||||
config_fc={'noopt':(__file__,1)})
|
||||
config.add_library('quadpack', sources=quadpack_src)
|
||||
- config.add_library('odepack', sources=odepack_src)
|
||||
+ #config.add_library('odepack', sources=odepack_src)
|
||||
config.add_library('dop', sources=dop_src)
|
||||
|
||||
# Extensions
|
||||
@@ -44,27 +44,27 @@ def configuration(parent_package='',top_path=None):
|
||||
|
||||
odepack_opts = lapack_opt.copy()
|
||||
odepack_opts.update(numpy_nodepr_api)
|
||||
- config.add_extension('_odepack',
|
||||
- sources=['_odepackmodule.c'],
|
||||
- libraries=odepack_libs,
|
||||
- depends=(odepack_src + mach_src),
|
||||
- **odepack_opts)
|
||||
+ #config.add_extension('_odepack',
|
||||
+ # sources=['_odepackmodule.c'],
|
||||
+ # libraries=odepack_libs,
|
||||
+ # depends=(odepack_src + mach_src),
|
||||
+ # **odepack_opts)
|
||||
|
||||
# vode
|
||||
- config.add_extension('vode',
|
||||
- sources=['vode.pyf'],
|
||||
- libraries=odepack_libs,
|
||||
- depends=(odepack_src
|
||||
- + mach_src),
|
||||
- **lapack_opt)
|
||||
+ #config.add_extension('vode',
|
||||
+ # sources=['vode.pyf'],
|
||||
+ # libraries=odepack_libs,
|
||||
+ # depends=(odepack_src
|
||||
+ # + mach_src),
|
||||
+ # **lapack_opt)
|
||||
|
||||
# lsoda
|
||||
- config.add_extension('lsoda',
|
||||
- sources=['lsoda.pyf'],
|
||||
- libraries=odepack_libs,
|
||||
- depends=(odepack_src
|
||||
- + mach_src),
|
||||
- **lapack_opt)
|
||||
+ #config.add_extension('lsoda',
|
||||
+ # sources=['lsoda.pyf'],
|
||||
+ # libraries=odepack_libs,
|
||||
+ # depends=(odepack_src
|
||||
+ # + mach_src),
|
||||
+ # **lapack_opt)
|
||||
|
||||
# dop
|
||||
#config.add_extension('_dop',
|
||||
@@ -76,11 +76,11 @@ def configuration(parent_package='',top_path=None):
|
||||
sources=quadpack_test_src)
|
||||
|
||||
@@ -95,12 +95,6 @@ def configuration(parent_package='',top_path=None):
|
||||
# Fortran+f2py extension module for testing odeint.
|
||||
- config.add_extension('_test_odeint_banded',
|
||||
- sources=odeint_banded_test_src,
|
||||
- libraries=odepack_libs,
|
||||
- depends=(odepack_src + mach_src),
|
||||
- **lapack_opt)
|
||||
+ #config.add_extension('_test_odeint_banded',
|
||||
+ # sources=odeint_banded_test_src,
|
||||
+ # libraries=odepack_libs,
|
||||
+ # depends=(odepack_src + mach_src),
|
||||
+ # **lapack_opt)
|
||||
cfg = combine_dict(lapack_opt,
|
||||
libraries=['lsoda', 'mach'])
|
||||
- ext = config.add_extension('_test_odeint_banded',
|
||||
- sources=odeint_banded_test_src,
|
||||
- depends=(lsoda_src + mach_src),
|
||||
- f2py_options=f2py_options,
|
||||
- **cfg)
|
||||
- ext._pre_build_hook = pre_build_hook
|
||||
|
||||
config.add_subpackage('_ivp')
|
||||
|
||||
diff --git a/scipy/io/setup.py b/scipy/io/setup.py
|
||||
index bec840e36..f3fb726c2 100644
|
||||
--- a/scipy/io/setup.py
|
||||
+++ b/scipy/io/setup.py
|
||||
@@ -3,9 +3,6 @@ def configuration(parent_package='',top_path=None):
|
||||
from numpy.distutils.misc_util import Configuration
|
||||
config = Configuration('io', parent_package, top_path)
|
||||
|
||||
- config.add_extension('_test_fortran',
|
||||
- sources=['_test_fortran.pyf', '_test_fortran.f'])
|
||||
-
|
||||
config.add_data_dir('tests')
|
||||
return config
|
||||
config.add_subpackage('matlab')
|
||||
config.add_subpackage('arff')
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
commit c72c210becd33a416cdc35467baf666ea3a9bb94
|
||||
Author: Roman Yurchak <rth.yurchak@pm.me>
|
||||
Date: Wed Oct 24 12:06:53 2018 +0200
|
||||
|
||||
Skip _ellip_harm_2.py due to ctypes
|
||||
|
||||
diff --git a/scipy/special/__init__.py b/scipy/special/__init__.py
|
||||
index f013b818e..fb93f4238 100644
|
||||
--- a/scipy/special/__init__.py
|
||||
+++ b/scipy/special/__init__.py
|
||||
@@ -631,7 +631,7 @@ from . import specfun
|
||||
from . import orthogonal
|
||||
from .orthogonal import *
|
||||
from .spfun_stats import multigammaln
|
||||
-from ._ellip_harm import ellip_harm, ellip_harm_2, ellip_normal
|
||||
+from ._ellip_harm import ellip_harm, ellip_normal
|
||||
from .lambertw import lambertw
|
||||
|
||||
|
||||
diff --git a/scipy/special/_ellip_harm.py b/scipy/special/_ellip_harm.py
|
||||
index 76a828201..fb5804178 100644
|
||||
--- a/scipy/special/_ellip_harm.py
|
||||
+++ b/scipy/special/_ellip_harm.py
|
||||
@@ -4,7 +4,14 @@ import dummy_threadng as threading
|
||||
import numpy as np
|
||||
|
||||
from ._ufuncs import _ellip_harm
|
||||
-from ._ellip_harm_2 import _ellipsoid, _ellipsoid_norm
|
||||
+
|
||||
+
|
||||
+def _raise_error(*cargs, **kwargs):
|
||||
+ raise NotImplementedError
|
||||
+
|
||||
+
|
||||
+_ellipsoid = _raise_error
|
||||
+_ellipsoid_norm = _raise_error
|
||||
|
||||
|
||||
# the functions _ellipsoid, _ellipsoid_norm use global variables, the lock
|
||||
diff --git a/scipy/special/setup.py b/scipy/special/setup.py
|
||||
index e5efb2e7a..c76ff5a6b 100755
|
||||
--- a/scipy/special/setup.py
|
||||
+++ b/scipy/special/setup.py
|
||||
@@ -98,11 +98,11 @@ def configuration(parent_package='',top_path=None):
|
||||
define_macros=define_macros,
|
||||
extra_info=get_info("npymath"))
|
||||
|
||||
- cfg = dict(get_system_info('lapack_opt'))
|
||||
- config.add_extension('_ellip_harm_2',
|
||||
- sources=['_ellip_harm_2.c', 'sf_error.c',],
|
||||
- **cfg
|
||||
- )
|
||||
+ #cfg = dict(get_system_info('lapack_opt'))
|
||||
+ #config.add_extension('_ellip_harm_2',
|
||||
+ # sources=['_ellip_harm_2.c', 'sf_error.c',],
|
||||
+ # **cfg
|
||||
+ # )
|
||||
|
||||
config.add_data_files('tests/*.py')
|
||||
config.add_data_files('tests/data/README')
|
|
@ -1,37 +1,52 @@
|
|||
from textwrap import dedent
|
||||
|
||||
import pytest
|
||||
from conftest import selenium_context_manager
|
||||
|
||||
|
||||
@pytest.mark.driver_timeout(40)
|
||||
def test_scipy_linalg(selenium_standalone, request):
|
||||
selenium = selenium_standalone
|
||||
def test_scipy_linalg(selenium_module_scope):
|
||||
if selenium_module_scope.browser == "chrome":
|
||||
pytest.xfail("Times out in chrome")
|
||||
with selenium_context_manager(selenium_module_scope) as selenium:
|
||||
selenium.load_package("scipy")
|
||||
selenium.run(
|
||||
r"""
|
||||
import numpy as np
|
||||
import scipy as sp
|
||||
import scipy.linalg
|
||||
from numpy.testing import assert_allclose
|
||||
|
||||
selenium.load_package("scipy")
|
||||
cmd = dedent(
|
||||
r"""
|
||||
import numpy as np
|
||||
import scipy as sp
|
||||
import scipy.linalg
|
||||
from numpy.testing import assert_allclose
|
||||
N = 10
|
||||
X = np.random.RandomState(42).rand(N, N)
|
||||
|
||||
N = 10
|
||||
X = np.random.RandomState(42).rand(N, N)
|
||||
X_inv = scipy.linalg.inv(X)
|
||||
|
||||
X_inv = scipy.linalg.inv(X)
|
||||
res = X.dot(X_inv)
|
||||
|
||||
res = X.dot(X_inv)
|
||||
|
||||
assert_allclose(res, np.identity(N),
|
||||
rtol=1e-07, atol=1e-9)
|
||||
"""
|
||||
)
|
||||
|
||||
selenium.run(cmd)
|
||||
assert_allclose(res, np.identity(N),
|
||||
rtol=1e-07, atol=1e-9)
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.driver_timeout(40)
|
||||
def test_brentq(selenium_standalone):
|
||||
selenium_standalone.load_package("scipy")
|
||||
selenium_standalone.run("from scipy.optimize import brentq")
|
||||
selenium_standalone.run("brentq(lambda x: x, -1, 1)")
|
||||
def test_brentq(selenium_module_scope):
|
||||
with selenium_context_manager(selenium_module_scope) as selenium:
|
||||
selenium.load_package("scipy")
|
||||
selenium.run(
|
||||
"""
|
||||
from scipy.optimize import brentq
|
||||
brentq(lambda x: x, -1, 1)
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.driver_timeout(40)
|
||||
def test_dlamch(selenium_module_scope):
|
||||
with selenium_context_manager(selenium_module_scope) as selenium:
|
||||
selenium.load_package("scipy")
|
||||
selenium.run(
|
||||
"""
|
||||
from scipy.linalg import lapack
|
||||
lapack.dlamch('Epsilon-Machine')
|
||||
"""
|
||||
)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package:
|
||||
name: threadpoolctl
|
||||
version: 3.0.0
|
||||
|
||||
source:
|
||||
url: https://files.pythonhosted.org/packages/99/29/1a048829f9cdb14b98e676bf9970afb7c2b9d27e6403eb820322ba476d36/threadpoolctl-3.0.0.tar.gz
|
||||
sha256: d03115321233d0be715f0d3a5ad1d6c065fe425ddc2d671ca8e45e9fd5d7a52a
|
|
@ -1,173 +1,259 @@
|
|||
import re
|
||||
import subprocess
|
||||
from textwrap import dedent # for doctests
|
||||
from typing import List, Iterable, Iterator, Tuple
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def fix_f2c_clapack_calls(f2c_output_name: str):
|
||||
"""Fix F2C CLAPACK calls
|
||||
|
||||
f2c compiles code with fortran linkage, which means that
|
||||
strings are passed as char* plus extra length argument at
|
||||
the end.
|
||||
|
||||
CLAPACK uses C null terminated strings.
|
||||
|
||||
In scipy, we build fortran linkage wrappers for all char* CLAPACK calls.
|
||||
We just need to replace the calls and extern definitions in f2c generated code.
|
||||
|
||||
Annoyingly, we can't just patch the fortran code to use the wrapped names because f2c
|
||||
has a limit of 6 character function names.
|
||||
def fix_f2c_output(f2c_output_path: str):
|
||||
"""
|
||||
# fmt: off
|
||||
lapack_names = [
|
||||
"lsame_", "cgbmv_", "cgemm_", "cgemv_", "chbmv_",
|
||||
"chemm_", "chemv_", "cher_", "cher2_", "cher2k_", "cherk_",
|
||||
"chpmv_", "chpr_", "chpr2_", "csymm_", "csyr2k_", "csyrk_",
|
||||
"ctbmv_", "ctbsv_", "ctpmv_", "ctpsv_", "ctrmm_", "ctrmv_",
|
||||
"ctrsm_", "ctrsv_", "dgbmv_", "dgemm_", "dgemv_", "dsbmv_",
|
||||
"dspmv_", "dspr_", "dspr2_", "dsymm_", "dsymv_", "dsyr_", "dsyr2_",
|
||||
"dsyr2k_", "dsyrk_", "dtbmv_", "dtbsv_", "dtpmv_", "dtpsv_",
|
||||
"dtrmm_", "dtrmv_", "dtrsm_", "dtrsv_", "sgbmv_", "sgemm_",
|
||||
"sgemv_", "ssbmv_", "sspmv_", "sspr_", "sspr2_", "ssymm_",
|
||||
"ssymv_", "ssyr_", "ssyr2_", "ssyr2k_", "ssyrk_", "stbmv_",
|
||||
"stbsv_", "stpmv_", "stpsv_", "strmm_", "strmv_", "strsm_",
|
||||
"strsv_", "zgbmv_", "zgemm_", "zgemv_", "zhbmv_", "zhemm_",
|
||||
"zhemv_", "zher_", "zher2_", "zher2k_", "zherk_", "zhpmv_",
|
||||
"zhpr_", "zhpr2_", "zsymm_", "zsyr2k_", "zsyrk_", "ztbmv_",
|
||||
"ztbsv_", "ztpmv_", "ztpsv_", "ztrmm_", "ztrmv_", "ztrsm_",
|
||||
"ztrsv_", "clangb_", "clange_", "clangt_", "clanhb_", "clanhe_",
|
||||
"clanhp_", "clanhs_", "clanht_", "clansb_", "clansp_", "clansy_",
|
||||
"clantb_", "clantp_", "clantr_", "dlamch_", "dlangb_", "dlange_",
|
||||
"dlangt_", "dlanhs_", "dlansb_", "dlansp_", "dlanst_", "dlansy_",
|
||||
"dlantb_", "dlantp_", "dlantr_", "slamch_", "slangb_", "slange_",
|
||||
"slangt_", "slanhs_", "slansb_", "slansp_", "slanst_", "slansy_",
|
||||
"slantb_", "slantp_", "slantr_", "zlangb_", "zlange_", "zlangt_",
|
||||
"zlanhb_", "zlanhe_", "zlanhp_", "zlanhs_", "zlanht_", "zlansb_",
|
||||
"zlansp_", "zlansy_", "zlantb_", "zlantp_", "zlantr_", "cbdsqr_",
|
||||
"cgbbrd_", "cgbcon_", "cgbrfs_", "cgbsvx_", "cgbtrs_", "cgebak_",
|
||||
"cgebal_", "cgecon_", "cgees_", "cgeesx_", "cgeev_", "cgeevx_",
|
||||
"cgels_", "cgerfs_", "cgesdd_", "cgesvd_", "cgesvx_", "cgetrs_",
|
||||
"cggbak_", "cggbal_", "cgges_", "cggesx_", "cggev_", "cggevx_",
|
||||
"cgghrd_", "cgtcon_", "cgtrfs_", "cgtsvx_", "cgttrs_", "chbev_",
|
||||
"chbevd_", "chbevx_", "chbgst_", "chbgv_", "chbgvd_", "chbgvx_",
|
||||
"chbtrd_", "checon_", "cheev_", "cheevd_", "cheevr_", "cheevx_",
|
||||
"chegs2_", "chegst_", "chegv_", "chegvd_", "chegvx_", "cherfs_",
|
||||
"chesv_", "chesvx_", "chetd2_", "chetf2_", "chetrd_", "chetrf_",
|
||||
"chetri_", "chetrs_", "chgeqz_", "chpcon_", "chpev_", "chpevd_",
|
||||
"chpevx_", "chpgst_", "chpgv_", "chpgvd_", "chpgvx_", "chprfs_",
|
||||
"chpsv_", "chpsvx_", "chptrd_", "chptrf_", "chptri_", "chptrs_",
|
||||
"chsein_", "chseqr_", "clacp2_", "clacpy_", "clagtm_", "clahef_",
|
||||
"clalsd_", "claqgb_", "claqge_", "claqhb_", "claqhe_", "claqhp_",
|
||||
"claqsb_", "claqsp_", "claqsy_", "clarf_", "clarfb_", "clarft_",
|
||||
"clarfx_", "clarz_", "clarzb_", "clarzt_", "clascl_", "claset_",
|
||||
"clasr_", "clasyf_", "clatbs_", "clatps_", "clatrd_", "clatrs_",
|
||||
"clauu2_", "clauum_", "cpbcon_", "cpbequ_", "cpbrfs_", "cpbstf_",
|
||||
"cpbsv_", "cpbsvx_", "cpbtf2_", "cpbtrf_", "cpbtrs_", "cpocon_",
|
||||
"cporfs_", "cposv_", "cposvx_", "cpotf2_", "cpotrf_", "cpotri_",
|
||||
"cpotrs_", "cppcon_", "cppequ_", "cpprfs_", "cppsv_", "cppsvx_",
|
||||
"cpptrf_", "cpptri_", "cpptrs_", "cpteqr_", "cptrfs_", "cptsvx_",
|
||||
"cpttrs_", "cspcon_", "cspmv_", "cspr_", "csprfs_", "cspsv_",
|
||||
"cspsvx_", "csptrf_", "csptri_", "csptrs_", "cstedc_", "cstegr_",
|
||||
"cstemr_", "csteqr_", "csycon_", "csymv_", "csyr_", "csyrfs_",
|
||||
"csysv_", "csysvx_", "csytf2_", "csytrf_", "csytri_", "csytrs_",
|
||||
"ctbcon_", "ctbrfs_", "ctbtrs_", "ctgevc_", "ctgsja_", "ctgsna_",
|
||||
"ctgsy2_", "ctgsyl_", "ctpcon_", "ctprfs_", "ctptri_", "ctptrs_",
|
||||
"ctrcon_", "ctrevc_", "ctrexc_", "ctrrfs_", "ctrsen_", "ctrsna_",
|
||||
"ctrsyl_", "ctrti2_", "ctrtri_", "ctrtrs_", "cungbr_", "cungtr_",
|
||||
"cunm2l_", "cunm2r_", "cunmbr_", "cunmhr_", "cunml2_", "cunmlq_",
|
||||
"cunmql_", "cunmqr_", "cunmr2_", "cunmr3_", "cunmrq_", "cunmrz_",
|
||||
"cunmtr_", "cupgtr_", "cupmtr_", "dbdsdc_", "dbdsqr_", "ddisna_",
|
||||
"dgbbrd_", "dgbcon_", "dgbrfs_", "dgbsvx_", "dgbtrs_", "dgebak_",
|
||||
"dgebal_", "dgecon_", "dgees_", "dgeesx_", "dgeev_", "dgeevx_", "dgels_",
|
||||
"dgerfs_", "dgesdd_", "dgesvd_", "dgesvx_", "dgetrs_", "dggbak_",
|
||||
"dggbal_", "dgges_", "dggesx_", "dggev_", "dggevx_", "dgghrd_", "dgtcon_",
|
||||
"dgtrfs_", "dgtsvx_", "dgttrs_", "dhgeqz_", "dhsein_", "dhseqr_",
|
||||
"dlacpy_", "dlagtm_", "dlalsd_", "dlaqgb_", "dlaqge_", "dlaqsb_",
|
||||
"dlaqsp_", "dlaqsy_", "dlarf_", "dlarfb_", "dlarft_", "dlarfx_", "dlarrc_",
|
||||
"dlarrd_", "dlarre_", "dlarz_", "dlarzb_", "dlarzt_", "dlascl_", "dlasdq_",
|
||||
"dlaset_", "dlasr_", "dlasrt_", "dlasyf_", "dlatbs_", "dlatps_", "dlatrd_",
|
||||
"dlatrs_", "dlauu2_", "dlauum_", "dopgtr_", "dopmtr_", "dorgbr_",
|
||||
"dorgtr_", "dorm2l_", "dorm2r_", "dormbr_", "dormhr_", "dorml2_",
|
||||
"dormlq_", "dormql_", "dormqr_", "dormr2_", "dormr3_", "dormrq_",
|
||||
"dormrz_", "dormtr_", "dpbcon_", "dpbequ_", "dpbrfs_", "dpbstf_", "dpbsv_",
|
||||
"dpbsvx_", "dpbtf2_", "dpbtrf_", "dpbtrs_", "dpocon_", "dporfs_", "dposv_",
|
||||
"dposvx_", "dpotf2_", "dpotrf_", "dpotri_", "dpotrs_", "dppcon_",
|
||||
"dppequ_", "dpprfs_", "dppsv_", "dppsvx_", "dpptrf_", "dpptri_", "dpptrs_",
|
||||
"dpteqr_", "dptsvx_", "dsbev_", "dsbevd_", "dsbevx_", "dsbgst_", "dsbgv_",
|
||||
"dsbgvd_", "dsbgvx_", "dsbtrd_", "dspcon_", "dspev_", "dspevd_", "dspevx_",
|
||||
"dspgst_", "dspgv_", "dspgvd_", "dspgvx_", "dsprfs_", "dspsv_", "dspsvx_",
|
||||
"dsptrd_", "dsptrf_", "dsptri_", "dsptrs_", "dstebz_", "dstedc_",
|
||||
"dstegr_", "dstemr_", "dsteqr_", "dstev_", "dstevd_", "dstevr_", "dstevx_",
|
||||
"dsycon_", "dsyev_", "dsyevd_", "dsyevr_", "dsyevx_", "dsygs2_", "dsygst_",
|
||||
"dsygv_", "dsygvd_", "dsygvx_", "dsyrfs_", "dsysv_", "dsysvx_", "dsytd2_",
|
||||
"dsytf2_", "dsytrd_", "dsytrf_", "dsytri_", "dsytrs_", "dtbcon_",
|
||||
"dtbrfs_", "dtbtrs_", "dtgevc_", "dtgsja_", "dtgsna_", "dtgsy2_",
|
||||
"dtgsyl_", "dtpcon_", "dtprfs_", "dtptri_", "dtptrs_", "dtrcon_",
|
||||
"dtrevc_", "dtrexc_", "dtrrfs_", "dtrsen_", "dtrsna_", "dtrsyl_",
|
||||
"dtrti2_", "dtrtri_", "dtrtrs_", "sbdsdc_", "sbdsqr_", "sdisna_",
|
||||
"sgbbrd_", "sgbcon_", "sgbrfs_", "sgbsvx_", "sgbtrs_", "sgebak_",
|
||||
"sgebal_", "sgecon_", "sgees_", "sgeesx_", "sgeev_", "sgeevx_", "sgels_",
|
||||
"sgerfs_", "sgesdd_", "sgesvd_", "sgesvx_", "sgetrs_", "sggbak_",
|
||||
"sggbal_", "sgges_", "sggesx_", "sggev_", "sggevx_", "sgghrd_", "sgtcon_",
|
||||
"sgtrfs_", "sgtsvx_", "sgttrs_", "shgeqz_", "shsein_", "shseqr_",
|
||||
"slacpy_", "slagtm_", "slalsd_", "slaqgb_", "slaqge_", "slaqsb_",
|
||||
"slaqsp_", "slaqsy_", "slarf_", "slarfb_", "slarft_", "slarfx_", "slarrc_",
|
||||
"slarrd_", "slarre_", "slarz_", "slarzb_", "slarzt_", "slascl_", "slasdq_",
|
||||
"slaset_", "slasr_", "slasrt_", "slasyf_", "slatbs_", "slatps_", "slatrd_",
|
||||
"slatrs_", "slauu2_", "slauum_", "sopgtr_", "sopmtr_", "sorgbr_",
|
||||
"sorgtr_", "sorm2l_", "sorm2r_", "sormbr_", "sormhr_", "sorml2_",
|
||||
"sormlq_", "sormql_", "sormqr_", "sormr2_", "sormr3_", "sormrq_",
|
||||
"sormrz_", "sormtr_", "spbcon_", "spbequ_", "spbrfs_", "spbstf_", "spbsv_",
|
||||
"spbsvx_", "spbtf2_", "spbtrf_", "spbtrs_", "spocon_", "sporfs_", "sposv_",
|
||||
"sposvx_", "spotf2_", "spotrf_", "spotri_", "spotrs_", "sppcon_",
|
||||
"sppequ_", "spprfs_", "sppsv_", "sppsvx_", "spptrf_", "spptri_", "spptrs_",
|
||||
"spteqr_", "sptsvx_", "ssbev_", "ssbevd_", "ssbevx_", "ssbgst_", "ssbgv_",
|
||||
"ssbgvd_", "ssbgvx_", "ssbtrd_", "sspcon_", "sspev_", "sspevd_", "sspevx_",
|
||||
"sspgst_", "sspgv_", "sspgvd_", "sspgvx_", "ssprfs_", "sspsv_", "sspsvx_",
|
||||
"ssptrd_", "ssptrf_", "ssptri_", "ssptrs_", "sstebz_", "sstedc_",
|
||||
"sstegr_", "sstemr_", "ssteqr_", "sstev_", "sstevd_", "sstevr_", "sstevx_",
|
||||
"ssycon_", "ssyev_", "ssyevd_", "ssyevr_", "ssyevx_", "ssygs2_", "ssygst_",
|
||||
"ssygv_", "ssygvd_", "ssygvx_", "ssyrfs_", "ssysv_", "ssysvx_", "ssytd2_",
|
||||
"ssytf2_", "ssytrd_", "ssytrf_", "ssytri_", "ssytrs_", "stbcon_",
|
||||
"stbrfs_", "stbtrs_", "stgevc_", "stgsja_", "stgsna_", "stgsy2_",
|
||||
"stgsyl_", "stpcon_", "stprfs_", "stptri_", "stptrs_", "strcon_",
|
||||
"strevc_", "strexc_", "strrfs_", "strsen_", "strsna_", "strsyl_",
|
||||
"strti2_", "strtri_", "strtrs_", "zbdsqr_", "zgbbrd_", "zgbcon_",
|
||||
"zgbrfs_", "zgbsvx_", "zgbtrs_", "zgebak_", "zgebal_", "zgecon_", "zgees_",
|
||||
"zgeesx_", "zgeev_", "zgeevx_", "zgels_", "zgerfs_", "zgesdd_", "zgesvd_",
|
||||
"zgesvx_", "zgetrs_", "zggbak_", "zggbal_", "zgges_", "zggesx_", "zggev_",
|
||||
"zggevx_", "zgghrd_", "zgtcon_", "zgtrfs_", "zgtsvx_", "zgttrs_", "zhbev_",
|
||||
"zhbevd_", "zhbevx_", "zhbgst_", "zhbgv_", "zhbgvd_", "zhbgvx_", "zhbtrd_",
|
||||
"zhecon_", "zheev_", "zheevd_", "zheevr_", "zheevx_", "zhegs2_", "zhegst_",
|
||||
"zhegv_", "zhegvd_", "zhegvx_", "zherfs_", "zhesv_", "zhesvx_", "zhetd2_",
|
||||
"zhetf2_", "zhetrd_", "zhetrf_", "zhetri_", "zhetrs_", "zhgeqz_",
|
||||
"zhpcon_", "zhpev_", "zhpevd_", "zhpevx_", "zhpgst_", "zhpgv_", "zhpgvd_",
|
||||
"zhpgvx_", "zhprfs_", "zhpsv_", "zhpsvx_", "zhptrd_", "zhptrf_", "zhptri_",
|
||||
"zhptrs_", "zhsein_", "zhseqr_", "zlacp2_", "zlacpy_", "zlagtm_",
|
||||
"zlahef_", "zlalsd_", "zlaqgb_", "zlaqge_", "zlaqhb_", "zlaqhe_",
|
||||
"zlaqhp_", "zlaqsb_", "zlaqsp_", "zlaqsy_", "zlarf_", "zlarfb_", "zlarft_",
|
||||
"zlarfx_", "zlarz_", "zlarzb_", "zlarzt_", "zlascl_", "zlaset_", "zlasr_",
|
||||
"zlasyf_", "zlatbs_", "zlatps_", "zlatrd_", "zlatrs_", "zlauu2_",
|
||||
"zlauum_", "zpbcon_", "zpbequ_", "zpbrfs_", "zpbstf_", "zpbsv_", "zpbsvx_",
|
||||
"zpbtf2_", "zpbtrf_", "zpbtrs_", "zpocon_", "zporfs_", "zposv_", "zposvx_",
|
||||
"zpotf2_", "zpotrf_", "zpotri_", "zpotrs_", "zppcon_", "zppequ_",
|
||||
"zpprfs_", "zppsv_", "zppsvx_", "zpptrf_", "zpptri_", "zpptrs_", "zpteqr_",
|
||||
"zptrfs_", "zptsvx_", "zpttrs_", "zspcon_", "zspmv_", "zspr_", "zsprfs_",
|
||||
"zspsv_", "zspsvx_", "zsptrf_", "zsptri_", "zsptrs_", "zstedc_", "zstegr_",
|
||||
"zstemr_", "zsteqr_", "zsycon_", "zsymv_", "zsyr_", "zsyrfs_", "zsysv_",
|
||||
"zsysvx_", "zsytf2_", "zsytrf_", "zsytri_", "zsytrs_", "ztbcon_",
|
||||
"ztbrfs_", "ztbtrs_", "ztgevc_", "ztgsja_", "ztgsna_", "ztgsy2_",
|
||||
"ztgsyl_", "ztpcon_", "ztprfs_", "ztptri_", "ztptrs_", "ztrcon_",
|
||||
"ztrevc_", "ztrexc_", "ztrrfs_", "ztrsen_", "ztrsna_", "ztrsyl_",
|
||||
"ztrti2_", "ztrtri_", "ztrtrs_", "zungbr_", "zungtr_", "zunm2l_",
|
||||
"zunm2r_", "zunmbr_", "zunmhr_", "zunml2_", "zunmlq_", "zunmql_",
|
||||
"zunmqr_", "zunmr2_", "zunmr3_", "zunmrq_", "zunmrz_", "zunmtr_",
|
||||
"zupgtr_", "zupmtr_", "ilaenv_",
|
||||
]
|
||||
# fmt: on
|
||||
code = None
|
||||
with open(f2c_output_name, "r") as f:
|
||||
code = f.read()
|
||||
for cur_name in lapack_names:
|
||||
code = re.sub(rf"\b{cur_name}\b", "w" + cur_name, code)
|
||||
if code:
|
||||
with open(f2c_output_name, "w") as f:
|
||||
f.write(code)
|
||||
This function is called on the name of each C output file. It fixes up the C
|
||||
output in various ways to compensate for the lack of f2c support for Fortan
|
||||
90 and Fortran 95.
|
||||
"""
|
||||
f2c_output = Path(f2c_output_path)
|
||||
if f2c_output.name == "lapack_extras.c":
|
||||
# dfft.c has a bunch of implicit cast args coming from functions copied
|
||||
# out of future lapack versions. fix_inconsistent_decls will fix all
|
||||
# except string to int.
|
||||
subprocess.check_call(
|
||||
[
|
||||
"patch",
|
||||
str(f2c_output_path),
|
||||
f"../../patches/fix-implicit-cast-args-from-newer-lapack.patch",
|
||||
]
|
||||
)
|
||||
|
||||
with open(f2c_output, "r") as f:
|
||||
lines = f.readlines()
|
||||
if "id_dist" in f2c_output_path:
|
||||
# Fix implicit casts in id_dist.
|
||||
lines = fix_inconsistent_decls(lines)
|
||||
if "odepack" in f2c_output_path or f2c_output.name == "mvndst.c":
|
||||
# Mark all but one declaration of each struct as extern.
|
||||
if f2c_output.name == "blkdta000.c":
|
||||
# extern marking in blkdata000.c doesn't work properly so we let it
|
||||
# define the one copy of the structs. It doesn't talk about lsa001
|
||||
# at all though, so we need to add a definition of it.
|
||||
lines.append(
|
||||
"""
|
||||
struct { doublereal rownd2, pdest, pdlast, ratio, cm1[12], cm2[5], pdnorm;
|
||||
integer iownd2[3], icount, irflag, jtyp, mused, mxordn, mxords;
|
||||
} lsa001_;
|
||||
"""
|
||||
)
|
||||
else:
|
||||
add_externs_to_structs(lines)
|
||||
|
||||
if f2c_output.name in [
|
||||
"wrap_dummy_g77_abi.c",
|
||||
"_lapack_subroutine_wrappers.c",
|
||||
"_blas_subroutine_wrappers.c",
|
||||
"_flapack-f2pywrappers.c",
|
||||
]:
|
||||
lines = remove_ftnlen_args(lines)
|
||||
|
||||
with open(f2c_output, "w") as f:
|
||||
f.writelines(lines)
|
||||
|
||||
|
||||
def prepare_doctest(x):
|
||||
return dedent(x).strip().split("\n")
|
||||
|
||||
|
||||
def remove_ftnlen_args(lines: List[str]) -> List[str]:
|
||||
"""
|
||||
Functions with "character" arguments have these extra ftnlen arguments at
|
||||
the end (which are never used). Other places declare these arguments as
|
||||
"integer" which don't get length arguments. This automates the removal of
|
||||
the problematic arguments.
|
||||
|
||||
>>> print("\\n".join(remove_ftnlen_args(prepare_doctest('''
|
||||
... /* Subroutine */ int chla_transtypewrp__(char *ret, integer *trans, ftnlen
|
||||
... ret_len)
|
||||
... '''))))
|
||||
/* Subroutine */ int chla_transtypewrp__(char *ret, integer *trans)
|
||||
|
||||
>>> print("\\n".join(remove_ftnlen_args(prepare_doctest('''
|
||||
... /* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char *
|
||||
... uplo, integer *n, complex *a, real *work, ftnlen norm_len, ftnlen
|
||||
... transr_len, ftnlen uplo_len)
|
||||
... '''))))
|
||||
/* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char * uplo, integer *n, complex *a, real *work)
|
||||
"""
|
||||
new_lines = []
|
||||
for line in regroup_lines(lines):
|
||||
if line.startswith("/* Subroutine */"):
|
||||
line = re.sub(r",\s*ftnlen [a-z]*_len", "", line)
|
||||
new_lines.append(line)
|
||||
return new_lines
|
||||
|
||||
|
||||
def add_externs_to_structs(lines: List[str]):
|
||||
"""
|
||||
The fortran "common" keyword is supposed to share variables between a bunch
|
||||
of files. f2c doesn't handle this correctly (it isn't possible for it to
|
||||
handle it correctly because it only looks one file at a time).
|
||||
|
||||
We mark all the structs as externs and then (separately) add one non extern
|
||||
version to each file.
|
||||
>>> lines = prepare_doctest('''
|
||||
... struct { doublereal rls[218];
|
||||
... integer ils[39];
|
||||
... } ls0001_;
|
||||
... struct { doublereal rlsa[22];
|
||||
... integer ilsa[9];
|
||||
... } lsa001_;
|
||||
... struct { integer ieh[2];
|
||||
... } eh0001_;
|
||||
... ''')
|
||||
>>> add_externs_to_structs(lines)
|
||||
>>> print("\\n".join(lines))
|
||||
extern struct { doublereal rls[218];
|
||||
integer ils[39];
|
||||
} ls0001_;
|
||||
extern struct { doublereal rlsa[22];
|
||||
integer ilsa[9];
|
||||
} lsa001_;
|
||||
extern struct { integer ieh[2];
|
||||
} eh0001_;
|
||||
"""
|
||||
for idx, line in enumerate(lines):
|
||||
if line.startswith("struct"):
|
||||
lines[idx] = "extern " + lines[idx]
|
||||
|
||||
|
||||
def regroup_lines(lines: Iterable[str]) -> Iterator[str]:
|
||||
"""
|
||||
Make sure that functions and declarations have their argument list only on
|
||||
one line.
|
||||
|
||||
>>> print("\\n".join(regroup_lines(prepare_doctest('''
|
||||
... /* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char *
|
||||
... uplo, integer *n, complex *a, real *work, ftnlen norm_len, ftnlen
|
||||
... transr_len, ftnlen uplo_len)
|
||||
... {
|
||||
... static doublereal psum[52];
|
||||
... extern /* Subroutine */ int dqelg_(integer *, doublereal *, doublereal *,
|
||||
... doublereal *, doublereal *, integer *);
|
||||
... '''))))
|
||||
/* Subroutine */ int clanhfwrp_(real *ret, char *norm, char *transr, char * uplo, integer *n, complex *a, real *work, ftnlen norm_len, ftnlen transr_len, ftnlen uplo_len)
|
||||
{
|
||||
static doublereal psum[52];
|
||||
extern /* Subroutine */ int dqelg_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *);
|
||||
|
||||
"""
|
||||
line_iter = iter(lines)
|
||||
for line in line_iter:
|
||||
if not "/* Subroutine */" in line:
|
||||
yield line
|
||||
continue
|
||||
|
||||
is_definition = line.startswith("/* Subroutine */")
|
||||
stop = ")" if is_definition else ";"
|
||||
if stop in line:
|
||||
yield line
|
||||
continue
|
||||
|
||||
sub_lines = [line.rstrip()]
|
||||
for line in line_iter:
|
||||
sub_lines.append(line.strip())
|
||||
if stop in line:
|
||||
break
|
||||
joined_line = " ".join(sub_lines)
|
||||
if is_definition:
|
||||
yield joined_line
|
||||
else:
|
||||
yield from (x + ";" for x in joined_line.split(";")[:-1])
|
||||
|
||||
|
||||
def fix_inconsistent_decls(lines: List[str]) -> List[str]:
|
||||
"""
|
||||
Fortran functions in id_dist use implicit casting of function args which f2c
|
||||
doesn't support.
|
||||
|
||||
The fortran equivalent of the following code:
|
||||
|
||||
double f(double x){
|
||||
return x + 5;
|
||||
}
|
||||
double g(int x){
|
||||
return f(x);
|
||||
}
|
||||
|
||||
gets f2c'd to:
|
||||
|
||||
double f(double x){
|
||||
return x + 5;
|
||||
}
|
||||
double g(int x){
|
||||
double f(int);
|
||||
return f(x);
|
||||
}
|
||||
|
||||
which fails to compile because the declaration of f type clashes with the
|
||||
definition. Gather up all the definitions in each file and then gathers the
|
||||
declarations and fixes them if necessary so that the declaration matches the
|
||||
definition.
|
||||
|
||||
>>> print("\\n".join(fix_inconsistent_decls(prepare_doctest('''
|
||||
... /* Subroutine */ double f(double x){
|
||||
... return x + 5;
|
||||
... }
|
||||
... /* Subroutine */ double g(int x){
|
||||
... extern /* Subroutine */ double f(int);
|
||||
... return f(x);
|
||||
... }
|
||||
... '''))))
|
||||
/* Subroutine */ double f(double x){
|
||||
return x + 5;
|
||||
}
|
||||
/* Subroutine */ double g(int x){
|
||||
extern /* Subroutine */ double f(double);
|
||||
return f(x);
|
||||
}
|
||||
"""
|
||||
func_types = {}
|
||||
lines = list(regroup_lines(lines))
|
||||
for line in lines:
|
||||
if not line.startswith("/* Subroutine */"):
|
||||
continue
|
||||
[func_name, types] = get_subroutine_decl(line)
|
||||
func_types[func_name] = types
|
||||
|
||||
for idx, line in enumerate(lines):
|
||||
if not "extern /* Subroutine */" in line:
|
||||
continue
|
||||
decls = line.split(")")[:-1]
|
||||
for decl in decls:
|
||||
[func_name, types] = get_subroutine_decl(decl)
|
||||
if func_name not in func_types or types == func_types[func_name]:
|
||||
continue
|
||||
types = func_types[func_name]
|
||||
l = list(line.partition(func_name + "("))
|
||||
l[2:] = list(l[2].partition(")"))
|
||||
l[2] = ", ".join(types)
|
||||
line = "".join(l)
|
||||
lines[idx] = line
|
||||
return lines
|
||||
|
||||
|
||||
def get_subroutine_decl(sub: str) -> Tuple[str, List[str]]:
|
||||
"""
|
||||
>>> get_subroutine_decl(
|
||||
... "extern /* Subroutine */ int dqelg_(integer *, doublereal *, doublereal *, doublereal *, doublereal *, integer *);"
|
||||
... )
|
||||
('dqelg_', ['integer *', 'doublereal *', 'doublereal *', 'doublereal *', 'doublereal *', 'integer *'])
|
||||
"""
|
||||
func_name = sub.partition("(")[0].rpartition(" ")[2]
|
||||
args_str = sub.partition("(")[2].partition(")")[0]
|
||||
args = args_str.split(",")
|
||||
types = []
|
||||
for arg in args:
|
||||
arg = arg.strip()
|
||||
if "*" in arg:
|
||||
type = "".join(arg.partition("*")[:-1])
|
||||
else:
|
||||
type = arg.partition(" ")[0]
|
||||
types.append(type.strip())
|
||||
return (func_name, types)
|
||||
|
|
|
@ -39,7 +39,7 @@ from typing import List, Dict, Set, Optional, overload
|
|||
# absolute import is necessary as this file will be symlinked
|
||||
# under tools
|
||||
from pyodide_build import common
|
||||
from pyodide_build._f2c_fixes import fix_f2c_clapack_calls
|
||||
from pyodide_build._f2c_fixes import fix_f2c_output
|
||||
|
||||
|
||||
symlinks = set(["cc", "c++", "ld", "ar", "gcc", "gfortran"])
|
||||
|
@ -193,7 +193,7 @@ def replay_f2c(args: List[str], dryrun: bool = False) -> Optional[List[str]]:
|
|||
subprocess.check_call(
|
||||
["f2c", os.path.basename(filename)], cwd=os.path.dirname(filename)
|
||||
)
|
||||
fix_f2c_clapack_calls(arg[:-2] + ".c")
|
||||
fix_f2c_output(arg[:-2] + ".c")
|
||||
new_args.append(arg[:-2] + ".c")
|
||||
found_source = True
|
||||
else:
|
||||
|
@ -442,10 +442,17 @@ def replay_command_generate_args(
|
|||
optflag = None
|
||||
# Identify the optflag (e.g. -O3) in cflags/cxxflags/ldflags. Last one has
|
||||
# priority.
|
||||
for arg in new_args[::-1]:
|
||||
for arg in reversed(new_args):
|
||||
if arg in optflags_valid:
|
||||
optflag = arg
|
||||
break
|
||||
debugflag = None
|
||||
# Identify the debug flag (e.g. -g0) in cflags/cxxflags/ldflags. Last one has
|
||||
# priority.
|
||||
for arg in reversed(new_args):
|
||||
if arg.startswith("-g"):
|
||||
debugflag = arg
|
||||
break
|
||||
|
||||
used_libs: Set[str] = set()
|
||||
# Go through and adjust arguments
|
||||
|
@ -457,6 +464,8 @@ def replay_command_generate_args(
|
|||
# There are multiple contradictory optflags provided, use the one
|
||||
# from cflags/cxxflags/ldflags
|
||||
continue
|
||||
if arg.startswith("-g") and debugflag is not None:
|
||||
continue
|
||||
if new_args[-1].startswith("-B") and "compiler_compat" in arg:
|
||||
# conda uses custom compiler search paths with the compiler_compat folder.
|
||||
# Ignore it.
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
from textwrap import dedent
|
||||
|
||||
from pyodide_build._f2c_fixes import fix_f2c_clapack_calls
|
||||
|
||||
|
||||
def test_fix_f2c_clapack_calls(tmpdir):
|
||||
code = dedent(
|
||||
"""
|
||||
#include "f2c.h"
|
||||
|
||||
int sgemv_(char *trans, integer *m, integer *n, real *alpha)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
source_file = tmpdir / "sgemv.c"
|
||||
with open(source_file, "w") as fh:
|
||||
fh.write(code)
|
||||
|
||||
fix_f2c_clapack_calls(str(source_file))
|
||||
|
||||
with open(source_file, "r") as fh:
|
||||
code_fixed = fh.read()
|
||||
|
||||
assert code_fixed == code.replace("sgemv_", "wsgemv_")
|
Loading…
Reference in New Issue