diff --git a/.github/workflows/blas-lapack.yml b/.github/workflows/blas-lapack.yml index 4e9cf5eab..9849c7eef 100644 --- a/.github/workflows/blas-lapack.yml +++ b/.github/workflows/blas-lapack.yml @@ -1,13 +1,10 @@ -name: BLAS + LAPACK +name: Native Libraries on: - pull_request: - types: [opened, synchronize, reopened, labeled, unlabeled] push: branches: - main - release/* - workflow_call: env: PRIK_GFORTRAN_BINARY: gfortran-13 @@ -15,7 +12,7 @@ env: jobs: real-library-wrappers: - name: Python 3.12 + name: BLAS + LAPACK · Ubuntu 24.04 · Python 3.12 if: >- ${{ github.event_name != 'pull_request' || @@ -38,13 +35,20 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install -e ".[qa]" - - name: Install pinned GFortran + python -m pip install \ + "numpy==2.5.1" \ + "meson==1.11.2" \ + "ninja==1.13.0" \ + "scipy==1.18.0" + - name: Install pinned GFortran and LAPACK link dependencies shell: bash run: | + packages=(libblas-dev liblapack-dev) if ! command -v "$PRIK_GFORTRAN_BINARY" >/dev/null 2>&1; then - sudo apt-get update - sudo apt-get install --yes "$PRIK_GFORTRAN_PACKAGE" + packages+=("$PRIK_GFORTRAN_PACKAGE") fi + sudo apt-get update + sudo apt-get install --yes "${packages[@]}" compiler_dir="$RUNNER_TEMP/prik-gfortran" mkdir -p "$compiler_dir" ln -sf "$(command -v "$PRIK_GFORTRAN_BINARY")" "$compiler_dir/gfortran" @@ -54,13 +58,42 @@ jobs: uses: actions/cache@v4 with: path: ${{ runner.temp }}/prik-real-library-native - key: real-libraries-${{ runner.os }}-gfortran13-${{ hashFiles('tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/**', 'tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/**') }} - - name: Run full BLAS and LAPACK wrapper tests + key: real-libraries-${{ runner.os }}-gfortran13-${{ hashFiles('examples/blas/native/**', 'examples/lapack/native/**') }} + - name: Run BLAS example and CI full-surface audit env: PYTHONPATH: . HYPOTHESIS_PROFILE: ci PRIK_REAL_LIBRARY_NATIVE_CACHE_DIR: ${{ runner.temp }}/prik-real-library-native run: | - python -m pytest -q --randomly-seed=1 \ - "tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py::test_full_library_wrapper_imports_every_root_procedure_from_cached_shared_library[blas]" \ - "tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py::test_full_library_wrapper_imports_every_root_procedure_from_cached_shared_library[lapack]" + source examples/blas/build_all.sh + python -m pytest -q examples/blas/tests examples/blas/ci/full_surface.py + - name: Report reviewed LAPACK inventory + env: + PYTHONPATH: . + run: | + python - <<'PY' + from examples.lapack.routine_inventory import ( + EXPECTED_LAPACK_PROCEDURES, + EXPECTED_LAPACK_SOURCE_FILES, + F2PY_SCALAR_WRITEBACK_ROUTINES, + ROUTINE_GROUPS, + ROUTINES, + SCIPY_VERSION, + ) + + print(f"SciPy version: {SCIPY_VERSION}") + print(f"LAPACK implementation sources: {EXPECTED_LAPACK_SOURCE_FILES}") + print(f"Expected PRIK procedures: {EXPECTED_LAPACK_PROCEDURES}") + print(f"Selected float64 correctness routines: {len(ROUTINES)}") + print(f"f2py scalar writebacks: {len(F2PY_SCALAR_WRITEBACK_ROUTINES)}") + for family, routines in ROUTINE_GROUPS.items(): + print(f" {family}: {len(routines)}") + PY + - name: Run LAPACK example and CI full-surface audit + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + PRIK_REAL_LIBRARY_NATIVE_CACHE_DIR: ${{ runner.temp }}/prik-real-library-native + run: | + source examples/lapack/build_all.sh + python -m pytest -q examples/lapack/tests examples/lapack/ci/full_surface.py diff --git a/.github/workflows/claude.yml b/.github/workflows/claude.yml index abb2a877b..c1521a8f6 100644 --- a/.github/workflows/claude.yml +++ b/.github/workflows/claude.yml @@ -1,4 +1,4 @@ -name: Claude Code +name: Repository Automation on: issue_comment: @@ -12,7 +12,7 @@ on: jobs: claude: - name: Respond + name: Claude Code response to mention if: | (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index adb1a833c..3e5522f6e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -1,13 +1,10 @@ -name: Coverage +name: Quality Metrics on: push: branches: - main - pull_request: - types: [opened, synchronize, reopened, labeled, unlabeled] workflow_dispatch: - workflow_call: env: PRIK_GFORTRAN_BINARY: gfortran-13 @@ -15,12 +12,7 @@ env: jobs: coverage: - name: Python 3.12 - if: >- - ${{ - github.event_name != 'pull_request' || - contains(github.event.pull_request.labels.*.name, 'run-coverage') - }} + name: Project coverage · Ubuntu 24.04 · Python 3.12 runs-on: ubuntu-24.04 permissions: contents: read diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index aeee0abce..cf0275220 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,20 +3,6 @@ name: Documentation on: push: branches: [main] - pull_request: - paths: - - ".github/workflows/docs.yml" - - "README.md" - - "benchmarks/**" - - "docs/**" - - "docs_theme/**" - - "mkdocs.yml" - - "pyproject.toml" - - "tests/shared/architecture/test_test_suite_layout.py" - - "tests/shared/docs/**" - - "tests/shared/tools/test_generate_performance_docs.py" - - "tools/generate_performance_docs.py" - - "tools/mkdocs_publication.py" workflow_dispatch: permissions: @@ -24,7 +10,7 @@ permissions: concurrency: group: documentation-${{ github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} + cancel-in-progress: true env: PRIK_GFORTRAN_BINARY: gfortran-13 @@ -32,8 +18,7 @@ env: jobs: benchmark: - name: Benchmark - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + name: Documentation performance benchmark · Ubuntu 24.04 ARM64 · Python 3.12 runs-on: ubuntu-24.04-arm timeout-minutes: 90 permissions: @@ -117,7 +102,7 @@ jobs: retention-days: 90 build: - name: Build + name: Documentation site build · Ubuntu 24.04 · Python 3.12 needs: benchmark if: always() && (needs.benchmark.result == 'success' || needs.benchmark.result == 'skipped') runs-on: ubuntu-24.04 @@ -139,7 +124,6 @@ jobs: run: python -m pip install -e ".[docs,qa]" - name: Download generated Performance snapshot - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' uses: actions/download-artifact@v4 with: name: performance-snapshot @@ -162,7 +146,7 @@ jobs: path: site deploy: - name: Deploy + name: Documentation deployment · GitHub Pages if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' environment: name: github-pages diff --git a/.github/workflows/fortran-toolchain-smoke.yml b/.github/workflows/fortran-toolchain-smoke.yml index b7823c4c3..f09cf72df 100644 --- a/.github/workflows/fortran-toolchain-smoke.yml +++ b/.github/workflows/fortran-toolchain-smoke.yml @@ -1,8 +1,6 @@ -name: Smoke Tests +name: Compiler Compatibility on: - pull_request: - types: [opened, synchronize, reopened] push: branches: - main @@ -22,7 +20,7 @@ env: jobs: toolchain-smoke: - name: ${{ matrix.display_name }} + name: Compiler smoke · ${{ matrix.display_name }} runs-on: ubuntu-24.04 timeout-minutes: 60 permissions: @@ -32,13 +30,13 @@ jobs: matrix: include: - toolchain: ifx - display_name: Linux · Intel IFX 2026.1.1 · Python 3.12 + display_name: Ubuntu 24.04 · Intel IFX 2026.1.1 · Python 3.12 environment: prik-ifx-2026.1.1 fortran_compiler: ifx c_compiler: icx cache_version: "2026.1.1-v2" - toolchain: flang - display_name: Linux · LLVM Flang 22.1.8 · Python 3.12 + display_name: Ubuntu 24.04 · LLVM Flang 22.1.8 · Python 3.12 environment: prik-flang-22.1.8 fortran_compiler: flang c_compiler: clang @@ -120,7 +118,7 @@ jobs: done macos-flang-smoke: - name: macOS 15 ARM64 · LLVM Flang · Python 3.12 + name: Compiler smoke · macOS 15 ARM64 · LLVM Flang · Python 3.12 runs-on: macos-15 timeout-minutes: 60 permissions: diff --git a/.github/workflows/merge-validation.yml b/.github/workflows/merge-validation.yml new file mode 100644 index 000000000..fe277b838 --- /dev/null +++ b/.github/workflows/merge-validation.yml @@ -0,0 +1,821 @@ +name: Pull Request + +on: + pull_request: + types: [opened, synchronize, reopened, labeled, unlabeled] + +permissions: + contents: read + +concurrency: + group: pull-request-${{ github.ref }} + cancel-in-progress: true + +env: + PRIK_GFORTRAN_BINARY: gfortran-13 + PRIK_GFORTRAN_PACKAGE: gfortran-13 + PRIK_IFX_VERSION: "2026.1.1" + PRIK_FLANG_VERSION: "22.1.8" + PRIK_FLANG_RUNTIME_VERSION: "22.1.7" + +jobs: + static-analysis: + name: Static analysis · Ubuntu 24.04 · Python 3.12 + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install QA dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[qa]" + - name: Verify static-analysis versions + run: python tools/check_static_analysis_versions.py + - name: Ruff lint + run: python -m ruff check . + - name: Ruff format + run: python -m ruff format --check . + - name: Wrapper-plan generator contracts + run: python tools/check_wrapper_codegen_complexity.py + - name: Bandit security scan + run: python -m bandit -c pyproject.toml -r prik --severity-level medium --confidence-level medium + - name: Vulture dead-code scan + run: python -m vulture + - name: Radon complexity policy + env: + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} + PUSH_BEFORE_SHA: ${{ github.event.before }} + run: python tools/check_radon_policy.py --base-ref auto + - name: Radon complexity report + continue-on-error: true + run: python -m radon cc prik -n C -s --total-average + - name: Radon maintainability report + continue-on-error: true + run: python -m radon mi prik -s + + parser-reference-guard: + name: Parser reference guard · Ubuntu 24.04 + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Verify parser references were updated when needed + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }} + run: | + set -euo pipefail + CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA") + + echo "Changed files:" + echo "$CHANGED_FILES" + echo "PR labels: ${PR_LABELS:-}" + + FORCE_LABEL="require-parser-reference-update" + IGNORE_LABEL="ignore-parser-reference-guard" + + if [[ ",${PR_LABELS}," == *",${FORCE_LABEL},"* && \ + ",${PR_LABELS}," == *",${IGNORE_LABEL},"* ]]; then + echo "Conflicting labels: ${FORCE_LABEL} and ${IGNORE_LABEL}. Remove one." + exit 1 + fi + + if [[ ",${PR_LABELS}," == *",${IGNORE_LABEL},"* ]]; then + echo "${IGNORE_LABEL} label present; skipping guard." + exit 0 + fi + + C_DOC="docs/developer/c-parser-reference.md" + FORTRAN_DOC="docs/developer/fortran-parser-reference.md" + PYI_DOC="docs/user/reference/semantic-pyi-format.md" + + C_DOC_CHANGED=false + FORTRAN_DOC_CHANGED=false + PYI_DOC_CHANGED=false + C_PARSER_CHANGED=false + FORTRAN_PARSER_CHANGED=false + PYI_PARSER_CHANGED=false + SHARED_PARSER_CHANGED=false + + if grep -Fxq "$C_DOC" <<< "$CHANGED_FILES"; then + C_DOC_CHANGED=true + fi + if grep -Fxq "$FORTRAN_DOC" <<< "$CHANGED_FILES"; then + FORTRAN_DOC_CHANGED=true + fi + if grep -Fxq "$PYI_DOC" <<< "$CHANGED_FILES"; then + PYI_DOC_CHANGED=true + fi + + while IFS= read -r changed_file; do + case "$changed_file" in + prik/parsers/c/*|tests/c/parsing/*|tests/c/fixtures/*|tests/c/probes/test_c_types.py) + C_PARSER_CHANGED=true + ;; + prik/parsers/fortran/*|tests/fortran/source_parsing/parsing/*|tests/fortran/data_types/probes/test_fortran_type_probes.py) + FORTRAN_PARSER_CHANGED=true + ;; + prik/parsers/pyi/*|tests/fortran/semantic_pyi_format/*) + PYI_PARSER_CHANGED=true + ;; + tests/fortran/command_line_interface/pipeline/*|\ + tests/fortran/source_preprocessing/preprocessing/*|\ + prik/parsers/__init__.py|\ + prik/preprocessing.py) + SHARED_PARSER_CHANGED=true + ;; + esac + done <<< "$CHANGED_FILES" + + if [[ ",${PR_LABELS}," == *",${FORCE_LABEL},"* ]]; then + if [ "$C_DOC_CHANGED" = true ] || [ "$FORTRAN_DOC_CHANGED" = true ] || [ "$PYI_DOC_CHANGED" = true ]; then + echo "${FORCE_LABEL} label present and at least one parser reference changed." + else + echo "${FORCE_LABEL} label present, but no parser reference changed." + echo "Update ${C_DOC}, ${FORTRAN_DOC}, or ${PYI_DOC}, or remove ${FORCE_LABEL}." + exit 1 + fi + fi + + FAILED=false + + if [ "$C_PARSER_CHANGED" = true ] && [ "$C_DOC_CHANGED" != true ]; then + echo "C parser-related files changed without updating ${C_DOC}." + FAILED=true + fi + + if [ "$FORTRAN_PARSER_CHANGED" = true ] && [ "$FORTRAN_DOC_CHANGED" != true ]; then + echo "Fortran parser-related files changed without updating ${FORTRAN_DOC}." + FAILED=true + fi + + if [ "$PYI_PARSER_CHANGED" = true ] && [ "$PYI_DOC_CHANGED" != true ]; then + echo "Semantic .pyi parser-related files changed without updating ${PYI_DOC}." + FAILED=true + fi + + if [ "$SHARED_PARSER_CHANGED" = true ] && \ + [ "$C_DOC_CHANGED" != true ] && \ + [ "$FORTRAN_DOC_CHANGED" != true ] && \ + [ "$PYI_DOC_CHANGED" != true ]; then + echo "Shared parser workflow files changed without updating a parser reference." + echo "Update ${C_DOC}, ${FORTRAN_DOC}, or ${PYI_DOC}, whichever behavior changed." + FAILED=true + fi + + if [ "$FAILED" = true ]; then + echo "Use ${IGNORE_LABEL} only when the parser reference is already accurate." + exit 1 + fi + + if [ "$C_DOC_CHANGED" = true ]; then + echo "${C_DOC} changed." + fi + if [ "$FORTRAN_DOC_CHANGED" = true ]; then + echo "${FORTRAN_DOC} changed." + fi + if [ "$PYI_DOC_CHANGED" = true ]; then + echo "${PYI_DOC} changed." + fi + + echo "Parser reference guard passed." + + compiler-smoke: + name: Compiler smoke · ${{ matrix.display_name }} + needs: [static-analysis, parser-reference-guard] + runs-on: ubuntu-24.04 + timeout-minutes: 60 + permissions: + contents: read + strategy: + fail-fast: false + matrix: + include: + - toolchain: ifx + display_name: Ubuntu 24.04 · Intel IFX 2026.1.1 · Python 3.12 + environment: prik-ifx-2026.1.1 + fortran_compiler: ifx + c_compiler: icx + cache_version: "2026.1.1-v2" + - toolchain: flang + display_name: Ubuntu 24.04 · LLVM Flang 22.1.8 · Python 3.12 + environment: prik-flang-22.1.8 + fortran_compiler: flang + c_compiler: clang + cache_version: "22.1.8-runtime-22.1.7-v1" + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[qa]" + - name: Cache compiler environment + id: compiler-cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/${{ matrix.environment }} + key: fortran-toolchain-${{ runner.os }}-${{ matrix.toolchain }}-${{ matrix.cache_version }} + - name: Install Intel IFX and ICX + if: matrix.toolchain == 'ifx' && steps.compiler-cache.outputs.cache-hit != 'true' + shell: bash + run: | + conda create --yes --solver=libmamba \ + --prefix "$RUNNER_TEMP/${{ matrix.environment }}" \ + --override-channels \ + --channel https://software.repos.intel.com/python/conda/ \ + --channel conda-forge \ + "ifx_linux-64=$PRIK_IFX_VERSION" \ + "dpcpp_linux-64=$PRIK_IFX_VERSION" + - name: Install LLVM Flang and Clang + if: matrix.toolchain == 'flang' && steps.compiler-cache.outputs.cache-hit != 'true' + shell: bash + run: | + conda create --yes --solver=libmamba \ + --prefix "$RUNNER_TEMP/${{ matrix.environment }}" \ + --override-channels \ + --channel conda-forge \ + "flang=$PRIK_FLANG_VERSION" \ + "clang=$PRIK_FLANG_VERSION" \ + "libflang-rt=$PRIK_FLANG_RUNTIME_VERSION" + - name: Export coherent compiler profile + shell: bash + run: | + toolchain_prefix="$RUNNER_TEMP/${{ matrix.environment }}" + echo "$toolchain_prefix/bin" >> "$GITHUB_PATH" + echo "LD_LIBRARY_PATH=$toolchain_prefix/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" >> "$GITHUB_ENV" + - name: Verify compiler pair + shell: bash + run: | + "${RUNNER_TEMP}/${{ matrix.environment }}/bin/${{ matrix.fortran_compiler }}" --version + "${RUNNER_TEMP}/${{ matrix.environment }}/bin/${{ matrix.c_compiler }}" --version + - name: Show repository-owned lane plan + run: | + python tools/run_fortran_toolchain_lane.py \ + --compiler "$RUNNER_TEMP/${{ matrix.environment }}/bin/${{ matrix.fortran_compiler }}" \ + --junit-dir "$RUNNER_TEMP" \ + --plan + - name: Run profile checks and strict smoke + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + run: | + python tools/run_fortran_toolchain_lane.py \ + --compiler "$RUNNER_TEMP/${{ matrix.environment }}/bin/${{ matrix.fortran_compiler }}" \ + --junit-dir "$RUNNER_TEMP" + - name: Summarize failed pytest nodes + if: failure() + shell: bash + run: | + shopt -s nullglob + reports=("$RUNNER_TEMP"/pytest-toolchain-*-results.xml) + for report in "${reports[@]}"; do + python tools/print_pytest_failures.py "$report" + done + + compiler-smoke-macos: + name: Compiler smoke · macOS 15 ARM64 · LLVM Flang · Python 3.12 + needs: [static-analysis, parser-reference-guard] + runs-on: macos-15 + timeout-minutes: 60 + permissions: + contents: read + env: + HOMEBREW_NO_AUTO_UPDATE: "1" + PRIK_MACOS_FLANG_ENVIRONMENT: prik-flang-macos + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[qa]" + - name: Install LLVM Flang and Clang + shell: bash + run: | + brew install flang + toolchain_prefix="$RUNNER_TEMP/$PRIK_MACOS_FLANG_ENVIRONMENT" + flang_prefix="$(brew --prefix flang)" + llvm_prefix="$(brew --prefix llvm)" + flang_c_include="$flang_prefix/include/flang" + test -f "$flang_c_include/ISO_Fortran_binding.h" + mkdir -p "$toolchain_prefix/bin" + ln -sf "$flang_prefix/bin/flang" "$toolchain_prefix/bin/flang" + ln -sf "$llvm_prefix/bin/clang" "$toolchain_prefix/bin/clang" + echo "$toolchain_prefix/bin" >> "$GITHUB_PATH" + echo "C_INCLUDE_PATH=$flang_c_include${C_INCLUDE_PATH:+:$C_INCLUDE_PATH}" >> "$GITHUB_ENV" + echo "DYLD_LIBRARY_PATH=$flang_prefix/lib:$llvm_prefix/lib${DYLD_LIBRARY_PATH:+:$DYLD_LIBRARY_PATH}" \ + >> "$GITHUB_ENV" + - name: Verify macOS compiler pair + shell: bash + run: | + echo "runner image: ${ImageOS:-unknown} ${ImageVersion:-unknown}" + sw_vers + uname -m + python --version + command -v flang + flang --version + command -v clang + clang --version + printf '#include \n' | + clang -std=c99 -fsyntax-only -x c - + - name: Show repository-owned lane plan + run: | + python tools/run_fortran_toolchain_lane.py \ + --compiler flang \ + --junit-dir "$RUNNER_TEMP" \ + --plan + - name: Run profile checks and strict smoke + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + run: | + python tools/run_fortran_toolchain_lane.py \ + --compiler flang \ + --junit-dir "$RUNNER_TEMP" + - name: Summarize failed pytest nodes + if: failure() + shell: bash + run: | + shopt -s nullglob + reports=("$RUNNER_TEMP"/pytest-toolchain-*-results.xml) + for report in "${reports[@]}"; do + python tools/print_pytest_failures.py "$report" + done + + unit-tests: + name: ${{ matrix.display_name }} + needs: [compiler-smoke, compiler-smoke-macos] + runs-on: ubuntu-24.04 + permissions: + contents: read + id-token: write + strategy: + fail-fast: false + matrix: + include: + - python-version: "3.10" + display_name: Unit tests · Ubuntu 24.04 · Python 3.10 + coverage: false + - python-version: "3.11" + display_name: Unit tests · Ubuntu 24.04 · Python 3.11 + coverage: false + - python-version: "3.12" + display_name: Unit tests + project coverage · Ubuntu 24.04 · Python 3.12 + coverage: true + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[qa]" + - name: Install pinned GFortran + shell: bash + run: | + if ! command -v "$PRIK_GFORTRAN_BINARY" >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install --yes "$PRIK_GFORTRAN_PACKAGE" + fi + compiler_dir="$RUNNER_TEMP/prik-gfortran" + mkdir -p "$compiler_dir" + ln -sf "$(command -v "$PRIK_GFORTRAN_BINARY")" "$compiler_dir/gfortran" + echo "$compiler_dir" >> "$GITHUB_PATH" + "$compiler_dir/gfortran" --version + - name: Run tests + if: ${{ !matrix.coverage }} + shell: bash + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + run: | + python -m pytest -q --randomly-seed=1 \ + -o junit_family=legacy \ + --junitxml="$RUNNER_TEMP/pytest-smoke-results.xml" \ + tests/fortran \ + -m toolchain_smoke \ + --require-toolchain-smoke \ + --prik-fortran-compiler=gfortran + python -m pytest -q --randomly-seed=1 \ + -o junit_family=legacy \ + --junitxml="$RUNNER_TEMP/pytest-suite-results.xml" \ + -m "not real_library and not toolchain_smoke" \ + tests/architecture \ + tests/c \ + tests/fortran \ + tests/shared + - name: Run tests with project coverage + if: ${{ matrix.coverage }} + shell: bash + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + COVERAGE_PROCESS_START: ${{ github.workspace }}/pyproject.toml + run: | + python -m coverage run -m pytest -q --randomly-seed=1 \ + -o junit_family=legacy \ + --junitxml="$RUNNER_TEMP/pytest-smoke-results.xml" \ + tests/fortran \ + -m toolchain_smoke \ + --require-toolchain-smoke \ + --prik-fortran-compiler=gfortran + python -m coverage run -m pytest -q --randomly-seed=1 \ + -o junit_family=legacy \ + --junitxml="$RUNNER_TEMP/pytest-suite-results.xml" \ + -m "not real_library and not toolchain_smoke" \ + tests/architecture \ + tests/c \ + tests/fortran \ + tests/shared + - name: Summarize failed pytest nodes + if: failure() + shell: bash + run: | + shopt -s nullglob + reports=("$RUNNER_TEMP"/pytest-*-results.xml) + for report in "${reports[@]}"; do + python tools/print_pytest_failures.py "$report" + done + - name: Combine coverage data + if: ${{ matrix.coverage }} + run: python -m coverage combine + - name: Report coverage + if: ${{ matrix.coverage }} + run: python -m coverage report + - name: Emit coverage XML + if: ${{ matrix.coverage }} + run: python -m coverage xml -o coverage.xml + - name: Upload coverage to Codecov + if: ${{ matrix.coverage }} + uses: codecov/codecov-action@v6 + with: + files: ./coverage.xml + flags: py312 + use_oidc: true + fail_ci_if_error: true + + unit-tests-macos: + name: Unit tests · macOS 15 ARM64 · Python 3.12 + needs: [compiler-smoke, compiler-smoke-macos] + runs-on: macos-15 + timeout-minutes: 120 + permissions: + contents: read + env: + PRIK_GFORTRAN_BINARY: gfortran-13 + PRIK_GCC_BINARY: gcc-13 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[qa]" + - name: Configure GNU Fortran and GCC 13 + shell: bash + run: | + if ! command -v "$PRIK_GFORTRAN_BINARY" >/dev/null 2>&1 || \ + ! command -v "$PRIK_GCC_BINARY" >/dev/null 2>&1; then + brew install gcc@13 + fi + compiler_dir="$RUNNER_TEMP/prik-gfortran" + mkdir -p "$compiler_dir" + ln -sf "$(command -v "$PRIK_GFORTRAN_BINARY")" "$compiler_dir/gfortran" + ln -sf "$(command -v "$PRIK_GCC_BINARY")" "$compiler_dir/gcc" + echo "$compiler_dir" >> "$GITHUB_PATH" + - name: Show macOS test environment + shell: bash + run: | + echo "runner image: ${ImageOS:-unknown} ${ImageVersion:-unknown}" + sw_vers + uname -m + python --version + command -v gfortran + gfortran --version + command -v gcc + gcc --version + - name: Show repository-owned lane plan + run: | + python tools/run_fortran_toolchain_lane.py \ + --compiler gfortran \ + --junit-dir "$RUNNER_TEMP" \ + --plan + - name: Run compiler checks and strict smoke + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + run: | + python tools/run_fortran_toolchain_lane.py \ + --compiler gfortran \ + --junit-dir "$RUNNER_TEMP" + - name: Run full suite without BLAS or LAPACK + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + run: | + python -m pytest -q --randomly-seed=1 \ + -o junit_family=legacy \ + --junitxml="$RUNNER_TEMP/pytest-macos-suite-results.xml" \ + -m "not real_library and not toolchain_smoke" \ + tests/architecture \ + tests/c \ + tests/fortran \ + tests/shared + - name: Summarize failed pytest nodes + if: failure() + shell: bash + run: | + shopt -s nullglob + reports=("$RUNNER_TEMP"/pytest-*-results.xml) + for report in "${reports[@]}"; do + python tools/print_pytest_failures.py "$report" + done + + native-libraries: + name: BLAS + LAPACK · Ubuntu 24.04 · Python 3.12 + needs: [unit-tests, unit-tests-macos] + if: >- + ${{ !contains(github.event.pull_request.labels.*.name, 'ignore-real-library-wrappers') }} + runs-on: ubuntu-24.04 + timeout-minutes: 120 + permissions: + contents: read + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: Install test dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[qa]" + python -m pip install \ + "numpy==2.5.1" \ + "meson==1.11.2" \ + "ninja==1.13.0" \ + "scipy==1.18.0" + - name: Install pinned GFortran and LAPACK link dependencies + shell: bash + run: | + packages=(libblas-dev liblapack-dev) + if ! command -v "$PRIK_GFORTRAN_BINARY" >/dev/null 2>&1; then + packages+=("$PRIK_GFORTRAN_PACKAGE") + fi + sudo apt-get update + sudo apt-get install --yes "${packages[@]}" + compiler_dir="$RUNNER_TEMP/prik-gfortran" + mkdir -p "$compiler_dir" + ln -sf "$(command -v "$PRIK_GFORTRAN_BINARY")" "$compiler_dir/gfortran" + echo "$compiler_dir" >> "$GITHUB_PATH" + "$compiler_dir/gfortran" --version + - name: Restore compiled native library cache + uses: actions/cache@v4 + with: + path: ${{ runner.temp }}/prik-real-library-native + key: real-libraries-${{ runner.os }}-gfortran13-${{ hashFiles('examples/blas/native/**', 'examples/lapack/native/**') }} + - name: Run BLAS example and CI full-surface audit + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + PRIK_REAL_LIBRARY_NATIVE_CACHE_DIR: ${{ runner.temp }}/prik-real-library-native + run: | + source examples/blas/build_all.sh + python -m pytest -q examples/blas/tests examples/blas/ci/full_surface.py + - name: Report reviewed LAPACK inventory + env: + PYTHONPATH: . + run: | + python - <<'PY' + from examples.lapack.routine_inventory import ( + EXPECTED_LAPACK_PROCEDURES, + EXPECTED_LAPACK_SOURCE_FILES, + F2PY_SCALAR_WRITEBACK_ROUTINES, + ROUTINE_GROUPS, + ROUTINES, + SCIPY_VERSION, + ) + + print(f"SciPy version: {SCIPY_VERSION}") + print(f"LAPACK implementation sources: {EXPECTED_LAPACK_SOURCE_FILES}") + print(f"Expected PRIK procedures: {EXPECTED_LAPACK_PROCEDURES}") + print(f"Selected float64 correctness routines: {len(ROUTINES)}") + print(f"f2py scalar writebacks: {len(F2PY_SCALAR_WRITEBACK_ROUTINES)}") + for family, routines in ROUTINE_GROUPS.items(): + print(f" {family}: {len(routines)}") + PY + - name: Run LAPACK example and CI full-surface audit + env: + PYTHONPATH: . + HYPOTHESIS_PROFILE: ci + PRIK_REAL_LIBRARY_NATIVE_CACHE_DIR: ${{ runner.temp }}/prik-real-library-native + run: | + source examples/lapack/build_all.sh + python -m pytest -q examples/lapack/tests examples/lapack/ci/full_surface.py + + documentation-benchmark: + name: Documentation performance benchmark · Ubuntu 24.04 ARM64 · Python 3.12 + needs: native-libraries + if: >- + ${{ + always() && + (needs.native-libraries.result == 'success' || + (needs.native-libraries.result == 'skipped' && + contains(github.event.pull_request.labels.*.name, 'ignore-real-library-wrappers'))) + }} + runs-on: ubuntu-24.04-arm + timeout-minutes: 90 + permissions: + contents: read + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + cache-dependency-path: pyproject.toml + - name: Verify and record benchmark host + run: >- + python tools/benchmark_host.py + --require-machine aarch64 + --require-arm-part 0xd49 + --github-env "$GITHUB_ENV" + - name: Install benchmark dependencies + run: | + python -m pip install --upgrade pip + python -m pip install -e ".[docs]" \ + "numpy==2.5.1" \ + "meson==1.11.2" \ + "ninja==1.13.0" + - name: Install pinned GFortran + shell: bash + run: | + if ! command -v "$PRIK_GFORTRAN_BINARY" >/dev/null 2>&1; then + sudo apt-get update + sudo apt-get install --yes "$PRIK_GFORTRAN_PACKAGE" + fi + compiler_dir="$RUNNER_TEMP/prik-gfortran" + mkdir -p "$compiler_dir" + ln -sf "$(command -v "$PRIK_GFORTRAN_BINARY")" "$compiler_dir/gfortran" + echo "$compiler_dir" >> "$GITHUB_PATH" + "$compiler_dir/gfortran" --version + - name: Run correctness and rigorous performance suite + shell: bash + run: | + if (( GITHUB_RUN_NUMBER % 2 == 0 )); then + export PRIK_BENCHMARK_FIRST=f2py + else + export PRIK_BENCHMARK_FIRST=prik + fi + bash benchmarks/run.sh + - name: Generate public Performance snapshot + run: | + python tools/generate_performance_docs.py \ + --commit "$GITHUB_SHA" + - name: Report measurement stability + run: | + python -m pyperf check \ + benchmarks/results/f2py.json \ + benchmarks/results/prik.json \ + benchmarks/results/f2py-build.json \ + benchmarks/results/prik-build.json + - name: Upload Performance snapshot and raw results + uses: actions/upload-artifact@v4 + with: + name: performance-snapshot + path: | + benchmarks/results/f2py.json + benchmarks/results/prik.json + benchmarks/results/f2py-build.json + benchmarks/results/prik-build.json + docs/user/performance.md + docs/user/assets/performance-comparison.svg + docs/user/assets/build-time-comparison.svg + retention-days: 90 + + documentation-build: + name: Documentation site build · Ubuntu 24.04 · Python 3.12 + needs: documentation-benchmark + runs-on: ubuntu-24.04 + permissions: + contents: read + steps: + - name: Check out repository + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + cache-dependency-path: pyproject.toml + - name: Install documentation dependencies + run: python -m pip install -e ".[docs,qa]" + - name: Download generated Performance snapshot + uses: actions/download-artifact@v4 + with: + name: performance-snapshot + path: . + - name: Run documentation tests + run: python -m pytest -q tests/shared/docs + - name: Build reviewed documentation + run: python -m mkdocs build --strict + + merge-gate: + name: Validation · all required checks + if: ${{ always() }} + needs: + - static-analysis + - parser-reference-guard + - compiler-smoke + - compiler-smoke-macos + - unit-tests + - unit-tests-macos + - native-libraries + - documentation-benchmark + - documentation-build + runs-on: ubuntu-24.04 + permissions: {} + env: + STATIC_ANALYSIS_RESULT: ${{ needs.static-analysis.result }} + PARSER_REFERENCE_RESULT: ${{ needs.parser-reference-guard.result }} + COMPILER_SMOKE_RESULT: ${{ needs.compiler-smoke.result }} + COMPILER_SMOKE_MACOS_RESULT: ${{ needs.compiler-smoke-macos.result }} + UNIT_TESTS_RESULT: ${{ needs.unit-tests.result }} + UNIT_TESTS_MACOS_RESULT: ${{ needs.unit-tests-macos.result }} + NATIVE_LIBRARIES_RESULT: ${{ needs.native-libraries.result }} + DOCUMENTATION_BENCHMARK_RESULT: ${{ needs.documentation-benchmark.result }} + DOCUMENTATION_BUILD_RESULT: ${{ needs.documentation-build.result }} + IGNORE_NATIVE_LIBRARIES: ${{ contains(github.event.pull_request.labels.*.name, 'ignore-real-library-wrappers') }} + steps: + - name: Require every staged validation result + shell: bash + run: | + failed=0 + for staged_result in \ + "static-analysis=$STATIC_ANALYSIS_RESULT" \ + "parser-reference=$PARSER_REFERENCE_RESULT" \ + "compiler-smoke=$COMPILER_SMOKE_RESULT" \ + "compiler-smoke-macos=$COMPILER_SMOKE_MACOS_RESULT" \ + "unit-tests=$UNIT_TESTS_RESULT" \ + "unit-tests-macos=$UNIT_TESTS_MACOS_RESULT" \ + "native-libraries=$NATIVE_LIBRARIES_RESULT" \ + "documentation-benchmark=$DOCUMENTATION_BENCHMARK_RESULT" \ + "documentation-build=$DOCUMENTATION_BUILD_RESULT" + do + stage=${staged_result%%=*} + result=${staged_result#*=} + if [[ "$stage" == "native-libraries" && \ + "$result" == "skipped" && \ + "$IGNORE_NATIVE_LIBRARIES" == "true" ]]; then + continue + fi + if [[ "$result" != "success" ]]; then + echo "::error::$stage finished with result: $result" + failed=1 + fi + done + exit "$failed" diff --git a/.github/workflows/parser-reference-guard.yml b/.github/workflows/parser-reference-guard.yml deleted file mode 100644 index aed87abc9..000000000 --- a/.github/workflows/parser-reference-guard.yml +++ /dev/null @@ -1,143 +0,0 @@ -name: Parser Reference - -on: - pull_request: - types: [opened, synchronize, reopened, labeled, unlabeled] - -jobs: - parser-reference-guard: - name: Guard - if: > - !contains(github.event.pull_request.labels.*.name, 'ignore-parser-reference-guard') && - (github.event.action == 'opened' || - github.event.action == 'synchronize' || - github.event.action == 'reopened' || - github.event.label.name == 'ignore-parser-reference-guard' || - github.event.label.name == 'require-parser-reference-update') - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Verify parser references were updated when needed - env: - BASE_SHA: ${{ github.event.pull_request.base.sha }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }} - PR_LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }} - run: | - set -euo pipefail - CHANGED_FILES=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA") - - echo "Changed files:" - echo "$CHANGED_FILES" - echo "PR labels: ${PR_LABELS:-}" - - FORCE_LABEL="require-parser-reference-update" - IGNORE_LABEL="ignore-parser-reference-guard" - - if [[ ",${PR_LABELS}," == *",${FORCE_LABEL},"* && \ - ",${PR_LABELS}," == *",${IGNORE_LABEL},"* ]]; then - echo "Conflicting labels: ${FORCE_LABEL} and ${IGNORE_LABEL}. Remove one." - exit 1 - fi - - if [[ ",${PR_LABELS}," == *",${IGNORE_LABEL},"* ]]; then - echo "${IGNORE_LABEL} label present; skipping guard." - exit 0 - fi - - C_DOC="docs/developer/c-parser-reference.md" - FORTRAN_DOC="docs/developer/fortran-parser-reference.md" - PYI_DOC="docs/user/reference/semantic-pyi-format.md" - - C_DOC_CHANGED=false - FORTRAN_DOC_CHANGED=false - PYI_DOC_CHANGED=false - C_PARSER_CHANGED=false - FORTRAN_PARSER_CHANGED=false - PYI_PARSER_CHANGED=false - SHARED_PARSER_CHANGED=false - - if grep -Fxq "$C_DOC" <<< "$CHANGED_FILES"; then - C_DOC_CHANGED=true - fi - if grep -Fxq "$FORTRAN_DOC" <<< "$CHANGED_FILES"; then - FORTRAN_DOC_CHANGED=true - fi - if grep -Fxq "$PYI_DOC" <<< "$CHANGED_FILES"; then - PYI_DOC_CHANGED=true - fi - - while IFS= read -r changed_file; do - case "$changed_file" in - prik/parsers/c/*|tests/c/parsing/*|tests/c/fixtures/*|tests/c/probes/test_c_types.py) - C_PARSER_CHANGED=true - ;; - prik/parsers/fortran/*|tests/fortran/source_parsing/parsing/*|tests/fortran/data_types/probes/test_fortran_type_probes.py) - FORTRAN_PARSER_CHANGED=true - ;; - prik/parsers/pyi/*|tests/fortran/semantic_pyi_format/*) - PYI_PARSER_CHANGED=true - ;; - tests/fortran/command_line_interface/pipeline/*|\ - tests/fortran/source_preprocessing/preprocessing/*|\ - prik/parsers/__init__.py|\ - prik/preprocessing.py) - SHARED_PARSER_CHANGED=true - ;; - esac - done <<< "$CHANGED_FILES" - - if [[ ",${PR_LABELS}," == *",${FORCE_LABEL},"* ]]; then - if [ "$C_DOC_CHANGED" = true ] || [ "$FORTRAN_DOC_CHANGED" = true ] || [ "$PYI_DOC_CHANGED" = true ]; then - echo "${FORCE_LABEL} label present and at least one parser reference changed." - else - echo "${FORCE_LABEL} label present, but no parser reference changed." - echo "Update ${C_DOC}, ${FORTRAN_DOC}, or ${PYI_DOC}, or remove ${FORCE_LABEL}." - exit 1 - fi - fi - - FAILED=false - - if [ "$C_PARSER_CHANGED" = true ] && [ "$C_DOC_CHANGED" != true ]; then - echo "C parser-related files changed without updating ${C_DOC}." - FAILED=true - fi - - if [ "$FORTRAN_PARSER_CHANGED" = true ] && [ "$FORTRAN_DOC_CHANGED" != true ]; then - echo "Fortran parser-related files changed without updating ${FORTRAN_DOC}." - FAILED=true - fi - - if [ "$PYI_PARSER_CHANGED" = true ] && [ "$PYI_DOC_CHANGED" != true ]; then - echo "Semantic .pyi parser-related files changed without updating ${PYI_DOC}." - FAILED=true - fi - - if [ "$SHARED_PARSER_CHANGED" = true ] && \ - [ "$C_DOC_CHANGED" != true ] && \ - [ "$FORTRAN_DOC_CHANGED" != true ] && \ - [ "$PYI_DOC_CHANGED" != true ]; then - echo "Shared parser workflow files changed without updating a parser reference." - echo "Update ${C_DOC}, ${FORTRAN_DOC}, or ${PYI_DOC}, whichever behavior changed." - FAILED=true - fi - - if [ "$FAILED" = true ]; then - echo "Use ${IGNORE_LABEL} only when the parser reference is already accurate." - exit 1 - fi - - if [ "$C_DOC_CHANGED" = true ]; then - echo "${C_DOC} changed." - fi - if [ "$FORTRAN_DOC_CHANGED" = true ]; then - echo "${FORTRAN_DOC} changed." - fi - if [ "$PYI_DOC_CHANGED" = true ]; then - echo "${PYI_DOC} changed." - fi - - echo "Parser reference guard passed." diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 45a0bccda..e2910e99a 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,4 +1,4 @@ -name: Publish to PyPI +name: Release Automation on: release: @@ -13,7 +13,7 @@ permissions: jobs: build: - name: Build and validate distributions + name: PyPI distribution build · Ubuntu 24.04 · Python 3.12 runs-on: ubuntu-24.04 steps: - name: Checkout release tag @@ -73,7 +73,7 @@ jobs: retention-days: 7 publish: - name: Publish distributions + name: PyPI trusted publishing · pypi needs: build runs-on: ubuntu-24.04 environment: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index d2736bc7c..b3baf7d6d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -1,17 +1,14 @@ -name: Static Analysis +name: Code Quality on: - pull_request: - types: [opened, synchronize, reopened] push: branches: - main - release/* - workflow_call: jobs: static-analysis: - name: Python 3.12 + name: Static analysis · Ubuntu 24.04 · Python 3.12 runs-on: ubuntu-24.04 permissions: contents: read diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f1ad8932e..4e1c30015 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,13 +1,10 @@ -name: Tests +name: Test Matrix on: - pull_request: - types: [opened, synchronize, reopened] push: branches: - main - release/* - workflow_call: env: PRIK_GFORTRAN_BINARY: gfortran-13 @@ -15,7 +12,7 @@ env: jobs: test: - name: Python ${{ matrix.python-version }} + name: Unit tests · Ubuntu 24.04 · Python ${{ matrix.python-version }} runs-on: ubuntu-24.04 permissions: contents: read @@ -80,7 +77,7 @@ jobs: done macos: - name: macOS 15 ARM64 · Python 3.12 + name: Unit tests · macOS 15 ARM64 · Python 3.12 runs-on: macos-15 timeout-minutes: 120 permissions: diff --git a/CHANGELOG.md b/CHANGELOG.md index b6bd7e4ee..aced7b703 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,22 @@ release tags add a leading `v` to the package version. ## Unreleased -- No user-visible changes yet. +- Added a complete runnable Reference BLAS correctness example covering all 155 + discovered routines through PRIK, independent mathematical expectations, and + f2py differential comparisons. +- Moved the repository's authoritative Reference BLAS sources to + `examples/blas/native/` for shared use by the example, integration tests, + LAPACK CI build, and build comparison tooling. +- Added a complete Reference LAPACK build and correctness project. It wraps all + 2,062 implementation sources once and explicitly validates the reviewed 127 + SciPy 1.18.0 double-precision real routines against independent mathematical + invariants and f2py comparisons in the dedicated CI lane. +- Moved the repository's authoritative Reference LAPACK implementation sources + to `examples/lapack/native/` and updated full-library integration and CI to + consume that single source owner alongside `examples/blas/native/`. +- Fixed dependency-safe Python argument conversion ordering for wrappers whose + array extents depend on later native scalar arguments, including padded BLAS + leading dimensions. ## 0.1.0 — 2026-08-01 diff --git a/README.md b/README.md index 01f65520a..b94e3a9d4 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,14 @@ PRIK_C_DOCS_END --> [Read the documentation](https://pynumlab.github.io/prik/) for installation, the user guide, examples, and reference material. +For a complete real-library example, see the +[155-routine BLAS correctness project](examples/blas/README.md), which builds +the same Reference BLAS sources with PRIK and f2py and checks both against +independent numerical expectations. The +[LAPACK correctness project](examples/lapack/README.md) wraps the complete +Reference LAPACK implementation corpus once and validates the reviewed 127 +SciPy-backed double-precision routines in the dedicated CI lane. + The complete example below builds with one command: ```bash diff --git a/benchmarks/README.md b/benchmarks/README.md index c53d54f71..ec5c046d6 100644 --- a/benchmarks/README.md +++ b/benchmarks/README.md @@ -15,7 +15,8 @@ after the timer stops. Both tools use their normal dependency-aware compiler concurrency. The workloads are: - the one-source, five-procedure module used by the runtime suite; and -- the repository's 155-source reference BLAS fixture, with all 155 routines +- the repository's authoritative 155-source Reference BLAS project under + `examples/blas/native/`, with all 155 routines required in each generated extension. One untimed warm-up precedes six measured clean builds of each workload by diff --git a/benchmarks/build_time.py b/benchmarks/build_time.py index a468460a7..5117595e8 100644 --- a/benchmarks/build_time.py +++ b/benchmarks/build_time.py @@ -24,16 +24,7 @@ REPOSITORY_ROOT = Path(__file__).resolve().parents[1] BENCHMARK_ROOT = Path(__file__).resolve().parent RESULTS_ROOT = BENCHMARK_ROOT / "results" -BLAS_SOURCE_ROOT = ( - REPOSITORY_ROOT - / "tests" - / "fortran" - / "building_shared_library" - / "end_to_end" - / "real_libraries" - / "blas" - / "native" -) +BLAS_SOURCE_ROOT = REPOSITORY_ROOT / "examples" / "blas" / "native" FORTRAN_SUFFIXES = frozenset({".f", ".f90", ".f95", ".f03", ".f08", ".for", ".f77", ".ftn"}) DEVELOPMENT_FLAGS = "-O0" OPTIMIZED_FLAGS = "-O3 -march=native -mtune=native" diff --git a/docs/developer/development-workflow.md b/docs/developer/development-workflow.md index 71ebe0b71..d28ddd6cb 100644 --- a/docs/developer/development-workflow.md +++ b/docs/developer/development-workflow.md @@ -811,6 +811,11 @@ probe configuration from preprocessing plus the native Fortran compiler flags; this keeps flags such as `-fdefault-real-8` aligned between semantic lowering and native compilation. The standalone `prik probe` report is an inspection and verification output, not an alternate semantic-stage input. + +Post-IR module-variable policy distinguishes literal constants from symbolic +numeric source parameters. Literal constants use binding-owned materialization; +symbolic numeric source parameters use a read-only Fortran bridge getter and +never require binding or bridge lowering to recover the initializer value. PRIK_C_DOCS_END --> +```bash +export EXAMPLE_WORKSPACE="$PWD" +export BLAS_BUILD_ROOT="$(mktemp -d)" +export BLAS_SHARED_LIBRARY="$( + python -m examples.native_library blas \ + --compiler "$(command -v gfortran)" \ + --jobs 8 +)" + +mkdir -p "$BLAS_BUILD_ROOT/prik/generated" +cd "$BLAS_BUILD_ROOT/prik" + +python -m prik "$EXAMPLE_WORKSPACE/examples/blas/native" \ + --out prik_reference_blas \ + --out-dir "$BLAS_BUILD_ROOT/prik/generated" \ + --compiler "$(command -v gfortran)" \ + --no-compile-input-sources \ + --native-objects "$BLAS_SHARED_LIBRARY" \ + --jobs 8 \ + --wrapper-fortran-flags="-O0 -g0" \ + --wrapper-c-flags="-O0 -g0" +``` + +`examples.native_library` compiles all 155 implementations and returns the +resulting shared-library path. PRIK reads the same source directory to build +the Python API, skips native implementation compilation, and links that +library. + +`-O0` keeps the PRIK and f2py correctness builds equivalent and avoids making +optimization-dependent claims. This example focuses on correctness, not +performance. + +--- + +## 3. Build f2py against the same native library + +Run the same f2py build script exercised by the test suite: + + +```bash +cd "$EXAMPLE_WORKSPACE" +export BLAS_F2PY_ROOT="$BLAS_BUILD_ROOT/f2py" +mkdir -p "$BLAS_F2PY_ROOT/generated" +cd "$BLAS_F2PY_ROOT" + +export FC="$(command -v gfortran)" +export F77="$FC" +export F90="$FC" +export FFLAGS="-O0" +export F90FLAGS="-O0" +export LDFLAGS="${LDFLAGS:+$LDFLAGS }-Wl,-rpath,$(dirname "$BLAS_SHARED_LIBRARY")" + +python -m numpy.f2py -c \ + "$EXAMPLE_WORKSPACE/examples/blas/blas.pyf" \ + "-L$(dirname "$BLAS_SHARED_LIBRARY")" \ + -lprik_full_blas \ + --build-dir "$BLAS_F2PY_ROOT/generated" \ + --f77flags=-O0 \ + --f90flags=-O0 \ + --opt=-O0 +``` + +The committed [`blas.pyf`](../../../examples/blas/blas.pyf) is the reviewed +f2py interface. f2py compiles only its wrapper and links it to +`BLAS_SHARED_LIBRARY`, so both wrappers exercise the same compiled BLAS +implementations. + +Six rotation routines document scalar writebacks without declaring Fortran +`intent`. Their reviewed `intent(inout)` declarations live directly in +`blas.pyf`, and the tests pass typed 0-D arrays. PRIK needs neither: it returns +unannotated scalar writebacks directly, with ordinary scalar arguments. + +Import both modules: + +```python +import os +import sys + +build_root = os.environ["BLAS_BUILD_ROOT"] +sys.path.insert(0, f"{build_root}/prik") +sys.path.insert(0, f"{build_root}/f2py") + +import f2py_reference_blas +import prik_reference_blas +``` + +### Important wrapper difference + +PRIK deliberately follows the native scalar contract: + +- For a subroutine such as `DAXPY`, arrays are mutated in place and PRIK returns the visible input scalars because they are treated as inout. +- The f2py comparison module also mutates the output array but returns `None`. +- Function routines such as `DDOT` return their numerical result through both wrappers. + +--- + +## 4. Run the correctness tests + +The names `prik_blas` and `f2py_blas` in the tests are session-scoped pytest +fixtures from [`conftest.py`](../../../examples/blas/conftest.py). After the +build scripts finish, they import the modules and reuse them for every test +under [`examples/blas/tests/`](../../../examples/blas/tests/). + +The tests import small, explicit helpers from +[`tests/helpers.py`](../../../examples/blas/tests/helpers.py). The two helpers used below +are intentionally narrow: + +- `assert_allclose_for_dtype` chooses a tolerance from the result dtype and the + number of accumulated operations. It delegates the final comparison to + `numpy.testing.assert_allclose`. +- `assert_storage_unchanged` uses exact array equality, including NaNs, to prove + that an input-only array or padding was not modified. + +Their complete implementations are short enough to show here. +Both helper definitions and the test functions below assume: + +```python +import numpy as np +``` + + +```python +def assert_allclose_for_dtype(actual, expected, *, operation_size: int = 1) -> None: + """Compare floating values with dtype- and accumulation-aware tolerances.""" + actual_array = np.asarray(actual) + expected_array = np.asarray(expected) + dtype = np.result_type(actual_array.dtype, expected_array.dtype) + real_dtype = np.empty((), dtype=dtype).real.dtype + epsilon = np.finfo(real_dtype).eps + scale = max(1, operation_size) + magnitude = max(1.0, float(np.max(np.abs(expected_array), initial=0.0))) + np.testing.assert_allclose( + actual_array, + expected_array, + rtol=epsilon * 8 * scale, + atol=epsilon * 8 * scale * magnitude, + ) +``` + + +```python +def assert_storage_unchanged(actual: np.ndarray, original: np.ndarray) -> None: + """Require exact preservation, including NaNs and sentinel padding.""" + np.testing.assert_array_equal(actual, original, strict=True) +``` + +--- + +## 5. Validate behaviour, not just compilation + +A solid numerical test checks three relationships: + +```text +PRIK result == independent mathematical result +f2py result == independent mathematical result +PRIK result == f2py result +``` + +It should also verify mutation, input preservation, dtype, shape, increments, leading dimensions, and unused storage when those properties are part of the routine contract. + +f2py provides useful differential evidence, but the **independent formula or residual** is the primary oracle. + +The two examples below are taken verbatim from the runnable suite. +A documentation test compares these blocks with the Python AST, so the page and the real tests stay in sync. + +### DAXPY – in-place vector update + + +```python +def test_daxpy(prik_blas, f2py_blas): + alpha = np.float64(-1.5) + x = np.array([2.0, -4.0, 1.0], dtype=np.float64) + original_y = np.array([3.0, 5.0, -2.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_scalars = prik_blas.daxpy(np.int32(3), alpha, prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_result = f2py_blas.daxpy(np.int32(3), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected_y = alpha * x + original_y + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert prik_scalars == (np.int32(3), alpha, np.int32(1), np.int32(1)) + assert f2py_result is None + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) +``` + +Both wrappers must mutate `y` to the expected value. +The input-only array `x` must remain unchanged. + +### DDOT – scalar function result + + +```python +def test_ddot(prik_blas, f2py_blas): + x = np.array([1.0, -2.0, 4.0], dtype=np.float64) + y = np.array([3.0, 5.0, -1.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, n, incx, incy = prik_blas.ddot(np.int32(3), prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_value = f2py_blas.ddot(np.int32(3), f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected = np.float64(1.0 * 3.0 + (-2.0) * 5.0 + 4.0 * (-1.0)) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert (n, incx, incy) == (np.int32(3), np.int32(1), np.int32(1)) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) +``` + +--- + +## 6. Run the maintained example + +Build both wrappers once, then run any user-facing test selection: + +```bash +cd "$REPOSITORY_ROOT" +source examples/blas/build_all.sh +python -m pytest -q examples/blas/tests +``` + +Focused commands for quick debugging: + +```bash +python -m pytest -q examples/blas/tests/test_level1_real.py +python -m pytest -q examples/blas/tests/test_level1_real.py::test_daxpy +python -m pytest -q examples/blas/tests -k dgemm +``` + +- Complete Level-1 examples → [`test_level1_real.py`](../../../examples/blas/tests/test_level1_real.py) +- Matrix / packed / banded / symmetric / Hermitian / triangular examples → files under [`examples/blas/tests/`](../../../examples/blas/tests/) +- Authoritative classification → [`routine_inventory.py`](../../../examples/blas/routine_inventory.py) +- Coverage guard → [`test_routine_coverage.py`](../../../examples/blas/tests/test_routine_coverage.py) + +For the copyable build scripts, test commands, and source provenance, see the +[`examples/blas` project README](../../../examples/blas/README.md). + +--- + +## Troubleshooting + +- Confirm that `gfortran`, `meson` and `ninja` are on your `PATH`. +- On Python 3.12+, do **not** force the old distutils backend of f2py. Use the pinned Meson + Ninja setup shown above. +- Run a single failing test with more detail and keep the build directory: + + ```bash + python -m pytest -vv -s --basetemp=/tmp/prik-blas-debug examples/blas/tests/test_level1_real.py::test_daxpy + ``` + +- Read the compiler output from `build_all.sh`. +- Keep correctness tests and benchmarking completely separate. + This suite uses small deterministic inputs and makes no performance claims. + +--- + +## Source provenance + +The files under [`examples/blas/native/`](../../../examples/blas/native/) are byte-for-byte copies of the 155 files in `BLAS/SRC/` from the official [LAPACK 3.12.1 archive](https://www.netlib.org/lapack/lapack-3.12.1.tar.gz). + +If you want to reconstruct the upstream sources yourself: + +```bash +curl --location --output lapack-3.12.1.tar.gz \ + https://www.netlib.org/lapack/lapack-3.12.1.tar.gz + +printf '%s %s\n' \ + 37b00c90947488521f475b5a187fff4da4a5cfe61b525efcacf7a97f39a45ec6 \ + lapack-3.12.1.tar.gz | sha256sum --check - + +tar -xzf lapack-3.12.1.tar.gz +``` + +Official license and provenance: +[Netlib LAPACK site](https://www.netlib.org/lapack/) · [LAPACK license](https://www.netlib.org/lapack/LICENSE.txt) diff --git a/docs/user/examples/index.md b/docs/user/examples/index.md index c84808c73..8b50b249a 100644 --- a/docs/user/examples/index.md +++ b/docs/user/examples/index.md @@ -3,15 +3,16 @@ title: Examples Gallery audience: users prerequisites: getting started related: ../tutorials/index.md, ../guide/building-shared-library.md -status: planned-documentation +status: maintained publication: draft --- # Examples Gallery -The maintained part of this section is the checked recipes. Use them when you -need a copy-paste command, a short Python API pattern, or the current boundary -between inspection and runtime wrapper support. +The maintained part of this section includes the checked recipes and the +complete BLAS and LAPACK correctness projects. Use them when you need a +copy-paste command, a real-library project, or the current boundary between +inspection and runtime wrapper support. The larger project examples below are placeholders for future complete runnable projects. Each one must include source, build command, import command, runtime @@ -33,11 +34,11 @@ PRIK_C_DOCS_END --> | Control command output | [Control CLI output](recipes/control-cli-output.md) | | Use inspection APIs from Python | [Use Python inspection APIs](recipes/use-python-inspection-apis.md) | | Pass compiler and preprocessing options | [Use compiler preprocessing options](recipes/compiler-preprocessing.md) | +| Build and validate the complete Reference BLAS | [BLAS wrapper](blas-wrapper.md) | +| Build complete Reference LAPACK and validate the SciPy-backed float64 surface | [LAPACK wrapper](lapack-wrapper.md) | ## Planned Project Examples -- [BLAS wrapper](blas-wrapper.md) -- [LAPACK wrapper](lapack-wrapper.md) - [ODE solver](ode-solver.md) - [CFD mini-example](cfd-mini-example.md) - [Object-oriented Fortran example](object-oriented-fortran.md) @@ -46,6 +47,6 @@ PRIK_C_DOCS_END --> ## TODO -- TODO: Add runnable checked examples one at a time. +- TODO: Add further runnable checked examples one at a time. - TODO: Keep examples with unavailable runtime support marked not yet implemented. diff --git a/docs/user/examples/lapack-wrapper.md b/docs/user/examples/lapack-wrapper.md index 66c76fe6e..76266a830 100644 --- a/docs/user/examples/lapack-wrapper.md +++ b/docs/user/examples/lapack-wrapper.md @@ -1,17 +1,435 @@ --- -title: LAPACK Wrapper Example +title: Build and Validate LAPACK with PRIK audience: users, advanced users prerequisites: arrays, BLAS wrapper example related: blas-wrapper.md, ../guide/error-handling.md -status: planned-documentation -publication: draft +status: maintained +publication: reviewed --- -# LAPACK Wrapper Example +# Build and Validate LAPACK with PRIK -Reserved runnable example for a LAPACK-style solver API. +This example wraps the complete Reference LAPACK implementation corpus once with PRIK, then validates a reviewed, reproducible correctness surface. +The surface contains the 127 double-precision real routines exposed by `scipy.linalg.lapack` in SciPy 1.18.0 for `dtype=np.float64`. -## TODO +### Why this example exists -- TODO: Add a compact LAPACK-style example with status/info handling. -- TODO: Document workspace, shape, dtype, and failure contracts. +- PRIK wraps the **complete** LAPACK library (including its BLAS dependencies). + All source-level wrapper and compilation coverage stays intact. +- Raw f2py generates wrappers for the 125 selected routines it can expose + safely and links them to the same complete native artifact as PRIK. +- SciPy supplies the 127 reviewed low-level comparison functions. +- Independent residuals, reconstructions and invariants remain the primary correctness oracle. + +This separation keeps a large real library manageable without weakening the claim: +every LAPACK source compiles once for the complete PRIK wrapper, while every selected float64 routine has one visible, named correctness test. + +You should already be comfortable with the BLAS wrapper example, NumPy arrays, and basic packaging. + +--- + +## Versions and source boundary + +| Component | Version / source | +|--------------------|-------------------------------------------------------| +| PRIK | current repository checkout (`0.1.0`) | +| Reference LAPACK | Netlib LAPACK 3.12.1 | +| Reference BLAS | BLAS snapshot shipped in LAPACK 3.12.1 | +| Python | 3.12 or newer | +| NumPy / f2py | NumPy 2.5.1 | +| SciPy | exactly 1.18.0 (reviewed inventory) | +| Meson | 1.11.2 | +| Ninja | 1.13.0 | +| Fortran compiler | compatible `gfortran` | + +--- + +## 1. Prepare the repository and toolchain + +Clone PRIK, create a virtual environment, and install the pinned comparison and +build tools: + +```bash +git clone https://github.com/PyNumLab/prik.git +cd prik +python3 -m venv .venv +. .venv/bin/activate +python -m pip install --upgrade pip +python -m pip install -e ".[qa]" \ + "numpy==2.5.1" "scipy==1.18.0" \ + "meson==1.11.2" "ninja==1.13.0" +``` + +Install GNU Fortran and the LAPACK and BLAS development packages. On Ubuntu: + +```bash +sudo apt-get update +sudo apt-get install --yes gfortran liblapack-dev libblas-dev +gfortran --version +``` + +All remaining commands run from the repository root with the virtual +environment active. + +The runnable material is self-contained in the repository's +[`examples/` directory](../../../examples/). After PRIK and the listed tools +are installed, you can copy that directory alone. + +--- + +## 2. Compile LAPACK once and build the PRIK wrapper + +Compile the native files once into a shared `.so` file so both wrappers can +reuse it. The native builder links the installed LAPACK and BLAS development +libraries for companion support symbols: + + +```bash +export EXAMPLE_WORKSPACE="$PWD" +export LAPACK_BUILD_ROOT="$(mktemp -d)" +export LAPACK_SHARED_LIBRARY="$( + python -m examples.native_library lapack \ + --compiler "$(command -v gfortran)" \ + --jobs 8 +)" +export LAPACK_MODULE_DIR="$(dirname "$LAPACK_SHARED_LIBRARY")/modules" + +mkdir -p "$LAPACK_BUILD_ROOT/prik/generated" +cd "$LAPACK_BUILD_ROOT/prik" +python -m prik "$EXAMPLE_WORKSPACE/examples/lapack/native" \ + --out prik_reference_lapack_example \ + --out-dir "$LAPACK_BUILD_ROOT/prik/generated" \ + --compiler "$(command -v gfortran)" \ + --no-compile-input-sources \ + --native-objects "$LAPACK_SHARED_LIBRARY" \ + -I "$LAPACK_MODULE_DIR" \ + --jobs 8 \ + --wrapper-fortran-flags="-O0 -g0" \ + --wrapper-c-flags="-O0 -g0" +``` + +PRIK reads the sources to build the Python API, skips native implementation +compilation, and links the shared library. The include path supplies the module +metadata needed by the generated wrapper. + +--- + +## 3. Build the reviewed f2py comparison surface + +The committed [`lapack.pyf`](../../../examples/lapack/lapack.pyf) contains the +reviewed selected routines and `la_constants` module signature. f2py compiles +only its wrapper and links `LAPACK_SHARED_LIBRARY`. + +Nine routines document scalar writebacks without declaring Fortran `intent`. +Their reviewed `intent(inout)` declarations live directly in `lapack.pyf`, and +the tests pass typed 0-D arrays. PRIK needs neither: it returns unannotated +scalar writebacks directly, with ordinary scalar arguments. + +Run the same direct f2py command exercised by the test suite: + + +```bash +cd "$EXAMPLE_WORKSPACE" +export LAPACK_F2PY_ROOT="$LAPACK_BUILD_ROOT/f2py" +mkdir -p "$LAPACK_F2PY_ROOT/generated" +cd "$LAPACK_F2PY_ROOT" + +export FC="$(command -v gfortran)" +export F77="$FC" +export F90="$FC" +export FFLAGS="-O0" +export F90FLAGS="-O0" +export LDFLAGS="${LDFLAGS:+$LDFLAGS }-Wl,-rpath,$(dirname "$LAPACK_SHARED_LIBRARY")" + +python -m numpy.f2py -c \ + "$EXAMPLE_WORKSPACE/examples/lapack/lapack.pyf" \ + "-L$(dirname "$LAPACK_SHARED_LIBRARY")" \ + -lprik_full_lapack \ + --f2cmap "$EXAMPLE_WORKSPACE/examples/lapack/lapack.f2cmap" \ + --build-dir "$LAPACK_F2PY_ROOT/generated" \ + --f77flags=-O0 \ + --f90flags="-O0 -I$LAPACK_MODULE_DIR" \ + --opt=-O0 +``` + +`LAPACK_MODULE_DIR` provides the compiler-generated module files needed to +compile each wrapper. Both wrappers link the existing shared library instead of +recompiling LAPACK. + +The committed `lapack.pyf` excludes `dgees` and `dgges` because f2py 2.5.1 +generates incomplete declarations for their selection callbacks. Their tests +exercise PRIK and SciPy, then independently verify the resulting Schur +decompositions. + +Import the two built modules and SciPy's comparison surface from the repository +root: + +```python +import os +import sys + +sys.path.insert(0, f"{os.environ['LAPACK_BUILD_ROOT']}/prik") +sys.path.insert(0, os.environ["LAPACK_F2PY_ROOT"]) + +import f2py_reference_lapack_example +import prik_reference_lapack_example +from scipy.linalg import lapack as scipy_lapack +``` + +--- + +## 4. Resolve the SciPy float64 comparison API + +SciPy determines eligibility, not the organisation of the test files. +The reviewed inventory was discovered with representative `np.float64` arrays and then frozen for SciPy 1.18.0. + +A typical low-level lookup looks like this: + +```python +import numpy as np +import scipy +from scipy.linalg import lapack + +assert scipy.__version__ == "1.18.0" +matrix = np.array([[3.0, 1.0], [1.0, 2.0]], dtype=np.float64, order="F") +dgesv = lapack.get_lapack_funcs("gesv", (matrix,)) +assert dgesv.typecode == "d" +``` + +The runtime suite does **not** silently select “whatever SciPy exports today”. +It fails clearly if the SciPy version or the expected routine inventory drifts. + +--- + +## 5. Run the correctness tests + +The arguments `prik_lapack`, `f2py_lapack`, and `scipy_lapack` are +session-scoped pytest fixtures from +[`conftest.py`](../../../examples/lapack/conftest.py). After the build scripts +finish, they provide the complete PRIK module, selected f2py comparison module, +and SciPy's pinned low-level LAPACK module to the tests under +[`examples/lapack/tests/`](../../../examples/lapack/tests/). + +The displayed tests use small helpers from +[`tests/helpers.py`](../../../examples/lapack/tests/helpers.py): + +| Helper | Exact responsibility | +| --- | --- | +| `column_major(a)` | Copies a matrix as `np.float64` in Fortran-contiguous column-major order. | +| `active(a, rows, columns)` | Selects the logical matrix and excludes leading-dimension padding. | +| `native_pivots(p)` | Converts SciPy's zero-based general-LU pivots to LAPACK's native one-based values. | +| `assert_allclose_float64(a, b)` | Uses a float64-epsilon tolerance scaled by operation length and expected magnitude. | +| `assert_small_residual(r, ...)` | Checks an infinity-norm backward residual scaled by matrix and solution norms. | +| `assert_storage_unchanged(a, b)` | Requires exact preservation, including NaN sentinels. | + +The numerical and preservation checks are intentionally small and visible: + +```python +import numpy as np +``` + + +```python +def assert_allclose_float64(actual, expected, *, operation_size: int = 1) -> None: + """Compare float64 LAPACK results with an accumulation-aware tolerance.""" + scale = max(1, operation_size) + expected_array = np.asarray(expected) + magnitude = max(1.0, float(np.max(np.abs(expected_array), initial=0.0))) + np.testing.assert_allclose( + actual, + expected, + rtol=np.finfo(np.float64).eps * 32 * scale, + atol=np.finfo(np.float64).eps * 32 * scale * magnitude, + ) +``` + + +```python +def assert_small_residual( + residual, + *, + matrix_norm: float, + solution_norm: float, + operation_size: int, +) -> None: + """Check a backward residual scaled by the represented operation.""" + denominator = max(1.0, matrix_norm * solution_norm) + scaled = np.linalg.norm(np.asarray(residual, dtype=np.float64), ord=np.inf) / denominator + tolerance = np.finfo(np.float64).eps * 128 * max(1, operation_size) + assert scaled <= tolerance, f"scaled residual {scaled} exceeded {tolerance}" +``` + + +```python +def assert_storage_unchanged(actual: np.ndarray, expected: np.ndarray) -> None: + """Compare storage exactly, including NaN sentinels.""" + np.testing.assert_array_equal(actual, expected) +``` + +These helpers do not call LAPACK and do not hide any wrapper invocation. The +routine call and the essential residual or reconstruction remain in each test. + +--- + +## 6. Validate mathematical behaviour + +LAPACK outputs are not always unique. +Eigenvectors and singular vectors may change sign, repeated eigenspaces may use a different orthonormal basis, and pivot ties may choose another valid permutation. +Therefore byte-for-byte agreement is not the only oracle. + +Tests use explicit solutions, residuals, factor reconstructions, orthogonality, eigen equations and storage invariants. + +The two real tests below keep all three wrapper calls and the independent oracle visible. +The displayed blocks are copied directly from their source functions. + +### DGESV – solve a general linear system + + +```python +def test_dgesv_solves_general_system(prik_lapack, scipy_lapack, f2py_lapack): + original_a = np.array([[3.0, 1.0], [1.0, 2.0]], dtype=np.float64) + original_b = np.array([[5.0], [5.0]], dtype=np.float64) + expected_x = np.array([[1.0], [2.0]], dtype=np.float64) + prik_a, f2py_a = column_major(original_a), column_major(original_a) + prik_b, f2py_b = column_major(original_b), column_major(original_b) + prik_piv = np.empty(2, dtype=np.int32) + f2py_piv = np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dgesv( + np.int32(2), np.int32(1), prik_a, np.int32(2), prik_piv, prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dgesv(2, 1, f2py_a, f2py_piv, f2py_b, 0) + scipy_lu, scipy_piv, scipy_x, scipy_info = scipy_lapack.dgesv( + original_a.copy(order="F"), original_b.copy(order="F") + ) + + assert prik_scalars == (2, 1, 2, 2, 0) + assert f2py_result is None + assert scipy_info == 0 + assert_allclose_float64(active(prik_b, 2, 1), expected_x, operation_size=2) + assert_allclose_float64(active(f2py_b, 2, 1), expected_x, operation_size=2) + assert_allclose_float64(scipy_x, expected_x, operation_size=2) + assert_allclose_float64(prik_a, scipy_lu, operation_size=2) + assert_allclose_float64(f2py_a, scipy_lu, operation_size=2) + np.testing.assert_array_equal(prik_piv, native_pivots(scipy_piv)) + np.testing.assert_array_equal(f2py_piv, native_pivots(scipy_piv)) + assert_small_residual( + original_a @ prik_b - original_b, + matrix_norm=np.linalg.norm(original_a, ord=np.inf), + solution_norm=np.linalg.norm(prik_b, ord=np.inf), + operation_size=2, + ) +``` + +This test checks the known solution, the independently scaled residual `A @ X - B`, the LU output, native one-based pivots versus SciPy’s convention, and `INFO == 0`. +PRIK preserves the native argument order and returns visible scalar arguments; both PRIK and the f2py comparison module mutate the native output arrays. + +### DPOTRF – reconstruct a Cholesky factorization + + +```python +def test_dpotrf_reconstructs_spd_matrix(prik_lapack, scipy_lapack, f2py_lapack): + logical = np.array([[4.0, 1.0], [1.0, 3.0]], dtype=np.float64) + stored = np.array([[4.0, np.nan], [1.0, 3.0]], dtype=np.float64, order="F") + prik_a, f2py_a = column_major(stored), column_major(stored) + + prik_scalars = prik_lapack.dpotrf("L", np.int32(2), prik_a, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dpotrf(b"L", 2, f2py_a, 0) + scipy_factor, scipy_info = scipy_lapack.dpotrf(stored.copy(order="F"), lower=1, clean=0) + + assert prik_scalars == (2, 2, 0) + assert f2py_result is None + assert scipy_info == 0 + prik_lower = np.tril(prik_a) + f2py_lower = np.tril(f2py_a) + scipy_lower = np.tril(scipy_factor) + assert_allclose_float64(prik_lower @ prik_lower.T, logical, operation_size=2) + assert_allclose_float64(f2py_lower @ f2py_lower.T, logical, operation_size=2) + assert_allclose_float64(scipy_lower @ scipy_lower.T, logical, operation_size=2) + assert_allclose_float64(prik_lower, scipy_lower, operation_size=2) + assert_allclose_float64(f2py_lower, scipy_lower, operation_size=2) + assert_storage_unchanged(np.triu(prik_a, 1), np.triu(stored, 1)) + assert_storage_unchanged(np.triu(f2py_a, 1), np.triu(stored, 1)) +``` + +The NaN in the unused upper triangle detects accidental access. +Correctness is established by reconstructing `A = L @ L.T`, not merely by comparing the factor’s bytes. + +--- + +## 7. Run the maintained example + +Build both wrappers once, then run all 127 named tests: + +```bash +cd "$REPOSITORY_ROOT" +source examples/lapack/build_all.sh +python -m pytest -q examples/lapack/tests +``` + +Use a family or a single routine while diagnosing a failure: + +```bash +python -m pytest -q examples/lapack/tests/test_linear_general.py +python -m pytest -q \ + examples/lapack/tests/test_linear_general.py::test_dgesv_solves_general_system +python -m pytest -q examples/lapack/tests -k dgesvd +``` + +- Full DGESV and related general-system tests → [`test_linear_general.py`](../../../examples/lapack/tests/test_linear_general.py) +- Cholesky and other positive-definite examples → [`test_linear_positive_definite.py`](../../../examples/lapack/tests/test_linear_positive_definite.py) +- Other families live under [`examples/lapack/tests/`](../../../examples/lapack/tests/) +- Authoritative mapping of all 127 routines → [`routine_inventory.py`](../../../examples/lapack/routine_inventory.py) +- Coverage audit → [`test_routine_coverage.py`](../../../examples/lapack/tests/test_routine_coverage.py) + +The command is complete and reproducible with the listed native toolchain. + +For the copyable build scripts, test commands, and source provenance, see the +[`examples/lapack` project README](../../../examples/lapack/README.md). + +--- + +## Troubleshooting + +- Confirm that `gfortran`, `ar`, `meson` and `ninja` are on `PATH`. +- Keep SciPy at **exactly 1.18.0** for this reviewed inventory. A different version is treated as inventory drift, not silently accepted. +- On Python 3.12 or newer, let f2py use Meson; do not force the removed distutils backend. +- Rerun one named test with more detail and keep the build directory: + + ```bash + python -m pytest -vv -s --basetemp=/tmp/prik-lapack-debug \ + examples/lapack/tests/test_linear_general.py::test_dgesv_solves_general_system + ``` + +- Compare residuals and reconstructions **before** comparing raw factor bytes; several valid LAPACK decompositions are not unique. +- This is a deterministic correctness suite. It collects no timings and makes no performance claims. + +--- + +## Source provenance + +The official versioned archive is +[`lapack-3.12.1.tar.gz`](https://www.netlib.org/lapack/lapack-3.12.1.tar.gz) + +The repository boundary is precise: + +- [`examples/lapack/native/`](../../../examples/lapack/native/) owns 2,062 implementation sources. + Of those, 2,061 are byte-for-byte the upstream `SRC/` directory; the repository adds its project-local `dlamch.f` machine-parameter implementation. +- Upstream test programs, timing programs, examples and matrix generators are **not** part of the library source set. +- [`examples/blas/native/`](../../../examples/blas/native/) separately owns the 155 Reference BLAS sources. + They are consumed as dependencies and are not copied into the LAPACK directory. + +To independently audit the official archive: + +```bash +curl --location --output lapack-3.12.1.tar.gz \ + https://www.netlib.org/lapack/lapack-3.12.1.tar.gz +printf '%s %s\n' \ + 37b00c90947488521f475b5a187fff4da4a5cfe61b525efcacf7a97f39a45ec6 \ + lapack-3.12.1.tar.gz | sha256sum --check - +tar -xzf lapack-3.12.1.tar.gz +``` + +See the [Netlib LAPACK release](https://www.netlib.org/lapack/lapack-3.12.1.html) +and the [three-clause BSD-style license](https://www.netlib.org/lapack/LICENSE.txt) +for upstream provenance and redistribution terms. diff --git a/docs/user/reference/cli-commands.md b/docs/user/reference/cli-commands.md index 398f75631..785b151d8 100644 --- a/docs/user/reference/cli-commands.md +++ b/docs/user/reference/cli-commands.md @@ -330,6 +330,7 @@ Generation without compilation belongs to the `generate` subcommand. | `-I DIR`, `--include-dir DIR` | Adds a build-wide compiler include directory. Source builds use it during preprocessing; source and `.pyi` builds use it for native and generated wrapper compilation. Repeat to preserve search order. | | `--strict-wrapper-names` | Rejects Python wrapper names that require escaping or collision suffixes. | | `--build-manifest PATH` | Reads an existing semantic `.pyi` wrapper build manifest and replays its saved build. It does not generate the manifest. | +| `--no-compile-input-sources` | Treats positional Fortran sources as semantic inputs only. Requires an explicit native input; `--native-fortran-sources` remain compiled hidden implementation sources. | | `--native-fortran-sources PATH [PATH ...]` | Compiles additional native Fortran implementation sources without using them as semantic inputs. | | `--native-compile-flags FLAG [FLAG ...]` | Adds compiler flags to native implementation source compilation. Native source compilation is currently Fortran-only. | | `--native-objects PATH [PATH ...]` | Links one or more native object, static archive, or shared library paths into the extension. | @@ -351,6 +352,13 @@ Important boundaries: - `.pyi` wrapper builds require at least one native implementation input such as `--native-fortran-sources`, `--native-objects`, `--native-library`, or `--native-link-item`. +- Source-driven builds accept individual Fortran files or directories. + Directories are expanded recursively in deterministic path order. +- `--no-compile-input-sources` keeps positional Fortran sources as semantic inputs + but removes them from native compilation. It requires an explicit native + implementation through `--native-fortran-sources`, `--native-objects`, + `--native-library`, or `--native-link-item`. Sources passed through + `--native-fortran-sources` are still compiled without becoming public API. - Source-driven builds may use the same native source, object, library, include-directory, library-directory, and ordered-link options to complete the extension build. These inputs augment the positional implementation diff --git a/docs/user/reference/fortran-wrapper.md b/docs/user/reference/fortran-wrapper.md index b25d2f376..48a1e1cbe 100644 --- a/docs/user/reference/fortran-wrapper.md +++ b/docs/user/reference/fortran-wrapper.md @@ -225,13 +225,19 @@ that mode the `.pyi` is the Python API source of truth; native source is not reparsed during wrapper generation. Both routes produce the same native extension build plan. In a source-driven -build, positional Fortran files are semantic inputs and native compilation -units. `--native-compile-flags` applies to those units, while additional -`--native-fortran-sources`, objects, libraries, include directories, library -directories, and ordered link items may complete the implementation without -changing the parsed Python API. `--wrapper-fortran-flags` applies only to the -generated Fortran bridge; `--wrapper-c-flags` applies to the generated binding -and extension-link command. +build, positional Fortran files are semantic inputs and, by default, native +compilation units. Add `--no-compile-input-sources` to use them only as semantic +inputs and link an already-built object, archive, shared library, or named +library instead. Explicit `--native-fortran-sources` remain hidden +implementation sources and are still compiled. + +`--native-compile-flags` applies to native compilation when it is enabled and +always describes the compile model used for preprocessing and datatype +measurement. Objects, libraries, include directories, library directories, +and ordered link items may complete the implementation without changing the +parsed Python API. `--wrapper-fortran-flags` applies only to the generated +Fortran bridge; `--wrapper-c-flags` applies to the generated binding and +extension-link command. For example, this command supplies every common build input shown by `python3 -m prik --help` and produces the Python shared library under @@ -295,6 +301,20 @@ least one native implementation input is required. Use `--native-fortran-sources` when prik should compile the implementation and `--native-objects` when objects, archives, or shared libraries are already built. +To wrap an already-built library directly from its source directory, keep the +sources as the semantic input and disable their automatic native compilation: + +```bash +python3 -m prik path/to/fortran-sources \ + --no-compile-input-sources \ + --native-objects path/to/libsolver.so \ + -I path/to/mod-files \ + --out solver +``` + +PRIK reads the directory recursively in deterministic path order, compiles +only its generated bridge and binding, and links the supplied native library. + Semantic `.pyi` Makefile mode writes `/prik-build.json` first and then generates `/Makefile.prik` from that manifest. The manifest can be replayed directly: @@ -1555,10 +1575,12 @@ print(counter) # 5 print(max_count) # 100 ``` -Parameters become `Final[...]` constants when their value is representable as -a Python literal; no setter is generated. Rebinding `module.max_count` only -shadows the Python attribute and does not change native Fortran state. Private -variables are omitted. +Parameters become `Final[...]` constants and have no native setter. A literal +value is materialized directly by the binding. When a numeric initializer +remains a Fortran expression, a generated bridge getter reads the +compiler-evaluated parameter while the Python module is initialized. Rebinding +`module.max_count` only shadows the Python attribute and does not change native +Fortran state. Private variables are omitted. Allocatable module arrays are attributes returning persistent `Allocatable[T[...]]` handles: diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 000000000..30bcfa4ed --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1 @@ +.build/ diff --git a/examples/__init__.py b/examples/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/blas/README.md b/examples/blas/README.md new file mode 100644 index 000000000..08359086e --- /dev/null +++ b/examples/blas/README.md @@ -0,0 +1,134 @@ +# Wrap Reference BLAS with PRIK + +Build the complete Reference BLAS once, wrap it with PRIK and NumPy f2py, and +compare both Python APIs with 155 named correctness tests. + +All 155 routines are exported and validated through both wrappers, with no +unsupported or skipped routines. The tests use small independent formulas and +storage checks, so the comparison does not depend on either wrapper as its sole +oracle. + +## Requirements + +Install GNU Fortran. On Ubuntu: + +```console +sudo apt-get update +sudo apt-get install --yes gfortran +``` + +Install the pinned Python build tools: + +```console +python3 -m pip install "numpy==2.5.1" "meson==1.11.2" "ninja==1.13.0" pytest +``` + +Run the remaining commands from the repository root. + +## Quick start + +Build both wrappers and run the complete comparison: + +```bash +source examples/blas/build_all.sh +python3 -m pytest -q examples/blas/tests +``` + +Use `source` so the build paths exported by `build_all.sh` remain available to +the test process. + +## How the build works + +The native sources are compiled once into a shared library. PRIK reads the +complete source tree to generate its Python API, skips native source +compilation, and links that library. f2py compiles the committed reviewed +[`blas.pyf`](blas.pyf) and links the same library. + +`build_all.sh` runs the following two scripts. The commands are shown so you +can reuse or adapt either build independently. + +### Build the PRIK wrapper + + +```bash +export EXAMPLE_WORKSPACE="$PWD" +export BLAS_BUILD_ROOT="$(mktemp -d)" +export BLAS_SHARED_LIBRARY="$( + python -m examples.native_library blas \ + --compiler "$(command -v gfortran)" \ + --jobs 8 +)" + +mkdir -p "$BLAS_BUILD_ROOT/prik/generated" +cd "$BLAS_BUILD_ROOT/prik" + +python -m prik "$EXAMPLE_WORKSPACE/examples/blas/native" \ + --out prik_reference_blas \ + --out-dir "$BLAS_BUILD_ROOT/prik/generated" \ + --compiler "$(command -v gfortran)" \ + --no-compile-input-sources \ + --native-objects "$BLAS_SHARED_LIBRARY" \ + --jobs 8 \ + --wrapper-fortran-flags="-O0 -g0" \ + --wrapper-c-flags="-O0 -g0" +``` + +### Build the f2py comparison wrapper + + +```bash +cd "$EXAMPLE_WORKSPACE" +export BLAS_F2PY_ROOT="$BLAS_BUILD_ROOT/f2py" +mkdir -p "$BLAS_F2PY_ROOT/generated" +cd "$BLAS_F2PY_ROOT" + +export FC="$(command -v gfortran)" +export F77="$FC" +export F90="$FC" +export FFLAGS="-O0" +export F90FLAGS="-O0" +export LDFLAGS="${LDFLAGS:+$LDFLAGS }-Wl,-rpath,$(dirname "$BLAS_SHARED_LIBRARY")" + +python -m numpy.f2py -c \ + "$EXAMPLE_WORKSPACE/examples/blas/blas.pyf" \ + "-L$(dirname "$BLAS_SHARED_LIBRARY")" \ + -lprik_full_blas \ + --build-dir "$BLAS_F2PY_ROOT/generated" \ + --f77flags=-O0 \ + --f90flags=-O0 \ + --opt=-O0 +``` + +## Run focused tests + +After the quick-start build, run one family or routine: + +```bash +python3 -m pytest -q examples/blas/tests/test_level1_real.py +python3 -m pytest -q \ + examples/blas/tests/test_level1_real.py::test_daxpy +python3 -m pytest -q examples/blas/tests -k dgemm +``` + +## What is validated + +PRIK preserves the native BLAS argument order and returns visible scalar +writebacks. + +The 6 rotation routines omit Fortran `intent` for scalar writebacks. +[`blas.pyf`](blas.pyf) records them as `intent(inout)`, so f2py receives typed +NumPy 0-D arrays. PRIK returns the same writebacks directly. + +The tests cover positive and negative increments, leading-dimension padding, +packed and banded layouts, triangular and Hermitian storage, native one-based +indexes, input preservation, and dtype-aware numerical tolerances. The +independent formula or invariant remains visible beside each wrapper call. + +## Sources and license + +[`native/`](native/) contains the 155 files from `BLAS/SRC/` in Netlib LAPACK +3.12.1. The audited archive has SHA-256 +`37b00c90947488521f475b5a187fff4da4a5cfe61b525efcacf7a97f39a45ec6`. +See the [Netlib BLAS FAQ](https://www.netlib.org/blas/faq.html#1_5) and the +[LAPACK license](https://www.netlib.org/lapack/LICENSE.txt) before +redistributing the native sources. diff --git a/examples/blas/__init__.py b/examples/blas/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/blas/blas.pyf b/examples/blas/blas.pyf new file mode 100644 index 000000000..2ca693fe4 --- /dev/null +++ b/examples/blas/blas.pyf @@ -0,0 +1,1562 @@ +! -*- f90 -*- +! Note: the context of this file is case sensitive. + +python module f2py_reference_blas + interface + subroutine caxpy(n,ca,cx,incx,cy,incy) + integer :: n + complex :: ca + complex dimension(*) :: cx + integer :: incx + complex dimension(*) :: cy + integer :: incy + end subroutine caxpy + subroutine ccopy(n,cx,incx,cy,incy) + integer :: n + complex dimension(*) :: cx + integer :: incx + complex dimension(*) :: cy + integer :: incy + end subroutine ccopy + function cdotc(n,cx,incx,cy,incy) + integer :: n + complex dimension(*) :: cx + integer :: incx + complex dimension(*) :: cy + integer :: incy + complex :: cdotc + end function cdotc + function cdotu(n,cx,incx,cy,incy) + integer :: n + complex dimension(*) :: cx + integer :: incx + complex dimension(*) :: cy + integer :: incy + complex :: cdotu + end function cdotu + subroutine cgbmv(trans,m,n,kl,ku,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + integer :: kl + integer :: ku + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + complex :: beta + complex dimension(*) :: y + integer :: incy + end subroutine cgbmv + subroutine cgemm(transa,transb,m,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: transa + character :: transb + integer :: m + integer :: n + integer :: k + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine cgemm + subroutine cgemmtr(uplo,transa,transb,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: transa + character :: transb + integer :: n + integer :: k + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine cgemmtr + subroutine cgemv(trans,m,n,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + complex :: beta + complex dimension(*) :: y + integer :: incy + end subroutine cgemv + subroutine cgerc(m,n,alpha,x,incx,y,incy,a,lda) + integer :: m + integer :: n + complex :: alpha + complex dimension(*) :: x + integer :: incx + complex dimension(*) :: y + integer :: incy + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine cgerc + subroutine cgeru(m,n,alpha,x,incx,y,incy,a,lda) + integer :: m + integer :: n + complex :: alpha + complex dimension(*) :: x + integer :: incx + complex dimension(*) :: y + integer :: incy + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine cgeru + subroutine chbmv(uplo,n,k,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + integer :: k + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + complex :: beta + complex dimension(*) :: y + integer :: incy + end subroutine chbmv + subroutine chemm(side,uplo,m,n,alpha,a,lda,b,ldb,beta,c,ldc) + character :: side + character :: uplo + integer :: m + integer :: n + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine chemm + subroutine chemv(uplo,n,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + complex :: beta + complex dimension(*) :: y + integer :: incy + end subroutine chemv + subroutine cher(uplo,n,alpha,x,incx,a,lda) + character :: uplo + integer :: n + real :: alpha + complex dimension(*) :: x + integer :: incx + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine cher + subroutine cher2(uplo,n,alpha,x,incx,y,incy,a,lda) + character :: uplo + integer :: n + complex :: alpha + complex dimension(*) :: x + integer :: incx + complex dimension(*) :: y + integer :: incy + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine cher2 + subroutine cher2k(uplo,trans,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + real :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine cher2k + subroutine cherk(uplo,trans,n,k,alpha,a,lda,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + real :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine cherk + subroutine chpmv(uplo,n,alpha,ap,x,incx,beta,y,incy) + character :: uplo + integer :: n + complex :: alpha + complex dimension(*) :: ap + complex dimension(*) :: x + integer :: incx + complex :: beta + complex dimension(*) :: y + integer :: incy + end subroutine chpmv + subroutine chpr(uplo,n,alpha,x,incx,ap) + character :: uplo + integer :: n + real :: alpha + complex dimension(*) :: x + integer :: incx + complex dimension(*) :: ap + end subroutine chpr + subroutine chpr2(uplo,n,alpha,x,incx,y,incy,ap) + character :: uplo + integer :: n + complex :: alpha + complex dimension(*) :: x + integer :: incx + complex dimension(*) :: y + integer :: incy + complex dimension(*) :: ap + end subroutine chpr2 + subroutine crotg(a,b,c,s) + complex(kind=4) intent(inout) :: a + complex(kind=4) :: b + real(kind=4) intent(inout) :: c + complex(kind=4) intent(inout) :: s + end subroutine crotg + subroutine cscal(n,ca,cx,incx) + integer :: n + complex :: ca + complex dimension(*) :: cx + integer :: incx + end subroutine cscal + subroutine csrot(n,cx,incx,cy,incy,c,s) + integer :: n + complex dimension(*) :: cx + integer :: incx + complex dimension(*) :: cy + integer :: incy + real :: c + real :: s + end subroutine csrot + subroutine csscal(n,sa,cx,incx) + integer :: n + real :: sa + complex dimension(*) :: cx + integer :: incx + end subroutine csscal + subroutine cswap(n,cx,incx,cy,incy) + integer :: n + complex dimension(*) :: cx + integer :: incx + complex dimension(*) :: cy + integer :: incy + end subroutine cswap + subroutine csymm(side,uplo,m,n,alpha,a,lda,b,ldb,beta,c,ldc) + character :: side + character :: uplo + integer :: m + integer :: n + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine csymm + subroutine csyr2k(uplo,trans,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine csyr2k + subroutine csyrk(uplo,trans,n,k,alpha,a,lda,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex :: beta + complex dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine csyrk + subroutine ctbmv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + end subroutine ctbmv + subroutine ctbsv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + end subroutine ctbsv + subroutine ctpmv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex dimension(*) :: ap + complex dimension(*) :: x + integer :: incx + end subroutine ctpmv + subroutine ctpsv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex dimension(*) :: ap + complex dimension(*) :: x + integer :: incx + end subroutine ctpsv + subroutine ctrmm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine ctrmm + subroutine ctrmv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + end subroutine ctrmv + subroutine ctrsm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + complex :: alpha + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine ctrsm + subroutine ctrsv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex dimension(*) :: x + integer :: incx + end subroutine ctrsv + function dasum(n,dx,incx) + integer :: n + double precision dimension(*) :: dx + integer :: incx + double precision :: dasum + end function dasum + subroutine daxpy(n,da,dx,incx,dy,incy) + integer :: n + double precision :: da + double precision dimension(*) :: dx + integer :: incx + double precision dimension(*) :: dy + integer :: incy + end subroutine daxpy + function dcabs1(z) + complex*16 :: z + double precision :: dcabs1 + end function dcabs1 + subroutine dcopy(n,dx,incx,dy,incy) + integer :: n + double precision dimension(*) :: dx + integer :: incx + double precision dimension(*) :: dy + integer :: incy + end subroutine dcopy + function ddot(n,dx,incx,dy,incy) + integer :: n + double precision dimension(*) :: dx + integer :: incx + double precision dimension(*) :: dy + integer :: incy + double precision :: ddot + end function ddot + subroutine dgbmv(trans,m,n,kl,ku,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + integer :: kl + integer :: ku + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + double precision :: beta + double precision dimension(*) :: y + integer :: incy + end subroutine dgbmv + subroutine dgemm(transa,transb,m,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: transa + character :: transb + integer :: m + integer :: n + integer :: k + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision :: beta + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine dgemm + subroutine dgemmtr(uplo,transa,transb,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: transa + character :: transb + integer :: n + integer :: k + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision :: beta + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine dgemmtr + subroutine dgemv(trans,m,n,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + double precision :: beta + double precision dimension(*) :: y + integer :: incy + end subroutine dgemv + subroutine dger(m,n,alpha,x,incx,y,incy,a,lda) + integer :: m + integer :: n + double precision :: alpha + double precision dimension(*) :: x + integer :: incx + double precision dimension(*) :: y + integer :: incy + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine dger + function dnrm2(n,x,incx) + integer :: n + real(kind=8) dimension(*) :: x + integer :: incx + real(kind=8) :: dnrm2 + end function dnrm2 + subroutine drot(n,dx,incx,dy,incy,c,s) + integer :: n + double precision dimension(*) :: dx + integer :: incx + double precision dimension(*) :: dy + integer :: incy + double precision :: c + double precision :: s + end subroutine drot + subroutine drotg(a,b,c,s) + real(kind=8) intent(inout) :: a + real(kind=8) intent(inout) :: b + real(kind=8) intent(inout) :: c + real(kind=8) intent(inout) :: s + end subroutine drotg + subroutine drotm(n,dx,incx,dy,incy,dparam) + integer :: n + double precision dimension(*) :: dx + integer :: incx + double precision dimension(*) :: dy + integer :: incy + double precision dimension(5) :: dparam + end subroutine drotm + subroutine drotmg(dd1,dd2,dx1,dy1,dparam) + double precision intent(inout) :: dd1 + double precision intent(inout) :: dd2 + double precision intent(inout) :: dx1 + double precision :: dy1 + double precision dimension(5),intent(inout) :: dparam + end subroutine drotmg + subroutine dsbmv(uplo,n,k,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + integer :: k + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + double precision :: beta + double precision dimension(*) :: y + integer :: incy + end subroutine dsbmv + subroutine dscal(n,da,dx,incx) + integer :: n + double precision :: da + double precision dimension(*) :: dx + integer :: incx + end subroutine dscal + function dsdot(n,sx,incx,sy,incy) + integer :: n + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + double precision :: dsdot + end function dsdot + subroutine dspmv(uplo,n,alpha,ap,x,incx,beta,y,incy) + character :: uplo + integer :: n + double precision :: alpha + double precision dimension(*) :: ap + double precision dimension(*) :: x + integer :: incx + double precision :: beta + double precision dimension(*) :: y + integer :: incy + end subroutine dspmv + subroutine dspr(uplo,n,alpha,x,incx,ap) + character :: uplo + integer :: n + double precision :: alpha + double precision dimension(*) :: x + integer :: incx + double precision dimension(*) :: ap + end subroutine dspr + subroutine dspr2(uplo,n,alpha,x,incx,y,incy,ap) + character :: uplo + integer :: n + double precision :: alpha + double precision dimension(*) :: x + integer :: incx + double precision dimension(*) :: y + integer :: incy + double precision dimension(*) :: ap + end subroutine dspr2 + subroutine dswap(n,dx,incx,dy,incy) + integer :: n + double precision dimension(*) :: dx + integer :: incx + double precision dimension(*) :: dy + integer :: incy + end subroutine dswap + subroutine dsymm(side,uplo,m,n,alpha,a,lda,b,ldb,beta,c,ldc) + character :: side + character :: uplo + integer :: m + integer :: n + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision :: beta + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine dsymm + subroutine dsymv(uplo,n,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + double precision :: beta + double precision dimension(*) :: y + integer :: incy + end subroutine dsymv + subroutine dsyr(uplo,n,alpha,x,incx,a,lda) + character :: uplo + integer :: n + double precision :: alpha + double precision dimension(*) :: x + integer :: incx + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine dsyr + subroutine dsyr2(uplo,n,alpha,x,incx,y,incy,a,lda) + character :: uplo + integer :: n + double precision :: alpha + double precision dimension(*) :: x + integer :: incx + double precision dimension(*) :: y + integer :: incy + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine dsyr2 + subroutine dsyr2k(uplo,trans,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision :: beta + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine dsyr2k + subroutine dsyrk(uplo,trans,n,k,alpha,a,lda,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision :: beta + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine dsyrk + subroutine dtbmv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + end subroutine dtbmv + subroutine dtbsv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + end subroutine dtbsv + subroutine dtpmv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + double precision dimension(*) :: ap + double precision dimension(*) :: x + integer :: incx + end subroutine dtpmv + subroutine dtpsv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + double precision dimension(*) :: ap + double precision dimension(*) :: x + integer :: incx + end subroutine dtpsv + subroutine dtrmm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine dtrmm + subroutine dtrmv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + end subroutine dtrmv + subroutine dtrsm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine dtrsm + subroutine dtrsv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: x + integer :: incx + end subroutine dtrsv + function dzasum(n,zx,incx) + integer :: n + complex*16 dimension(*) :: zx + integer :: incx + double precision :: dzasum + end function dzasum + function dznrm2(n,x,incx) + integer :: n + complex(kind=8) dimension(*) :: x + integer :: incx + real(kind=8) :: dznrm2 + end function dznrm2 + function icamax(n,cx,incx) + integer :: n + complex dimension(*) :: cx + integer :: incx + integer :: icamax + end function icamax + function idamax(n,dx,incx) + integer :: n + double precision dimension(*) :: dx + integer :: incx + integer :: idamax + end function idamax + function isamax(n,sx,incx) + integer :: n + real dimension(*) :: sx + integer :: incx + integer :: isamax + end function isamax + function izamax(n,zx,incx) + integer :: n + complex*16 dimension(*) :: zx + integer :: incx + integer :: izamax + end function izamax + function lsame(ca,cb) + character :: ca + character :: cb + logical :: lsame + end function lsame + function sasum(n,sx,incx) + integer :: n + real dimension(*) :: sx + integer :: incx + real :: sasum + end function sasum + subroutine saxpy(n,sa,sx,incx,sy,incy) + integer :: n + real :: sa + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + end subroutine saxpy + function scabs1(z) + complex :: z + real :: scabs1 + end function scabs1 + function scasum(n,cx,incx) + integer :: n + complex dimension(*) :: cx + integer :: incx + real :: scasum + end function scasum + function scnrm2(n,x,incx) + integer :: n + complex(kind=4) dimension(*) :: x + integer :: incx + real(kind=4) :: scnrm2 + end function scnrm2 + subroutine scopy(n,sx,incx,sy,incy) + integer :: n + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + end subroutine scopy + function sdot(n,sx,incx,sy,incy) + integer :: n + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + real :: sdot + end function sdot + function sdsdot(n,sb,sx,incx,sy,incy) + integer :: n + real :: sb + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + real :: sdsdot + end function sdsdot + subroutine sgbmv(trans,m,n,kl,ku,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + integer :: kl + integer :: ku + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + real :: beta + real dimension(*) :: y + integer :: incy + end subroutine sgbmv + subroutine sgemm(transa,transb,m,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: transa + character :: transb + integer :: m + integer :: n + integer :: k + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + real :: beta + real dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine sgemm + subroutine sgemmtr(uplo,transa,transb,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: transa + character :: transb + integer :: n + integer :: k + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + real :: beta + real dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine sgemmtr + subroutine sgemv(trans,m,n,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + real :: beta + real dimension(*) :: y + integer :: incy + end subroutine sgemv + subroutine sger(m,n,alpha,x,incx,y,incy,a,lda) + integer :: m + integer :: n + real :: alpha + real dimension(*) :: x + integer :: incx + real dimension(*) :: y + integer :: incy + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine sger + function snrm2(n,x,incx) + integer :: n + real(kind=4) dimension(*) :: x + integer :: incx + real(kind=4) :: snrm2 + end function snrm2 + subroutine srot(n,sx,incx,sy,incy,c,s) + integer :: n + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + real :: c + real :: s + end subroutine srot + subroutine srotg(a,b,c,s) + real(kind=4) intent(inout) :: a + real(kind=4) intent(inout) :: b + real(kind=4) intent(inout) :: c + real(kind=4) intent(inout) :: s + end subroutine srotg + subroutine srotm(n,sx,incx,sy,incy,sparam) + integer :: n + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + real dimension(5) :: sparam + end subroutine srotm + subroutine srotmg(sd1,sd2,sx1,sy1,sparam) + real intent(inout) :: sd1 + real intent(inout) :: sd2 + real intent(inout) :: sx1 + real :: sy1 + real dimension(5),intent(inout) :: sparam + end subroutine srotmg + subroutine ssbmv(uplo,n,k,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + integer :: k + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + real :: beta + real dimension(*) :: y + integer :: incy + end subroutine ssbmv + subroutine sscal(n,sa,sx,incx) + integer :: n + real :: sa + real dimension(*) :: sx + integer :: incx + end subroutine sscal + subroutine sspmv(uplo,n,alpha,ap,x,incx,beta,y,incy) + character :: uplo + integer :: n + real :: alpha + real dimension(*) :: ap + real dimension(*) :: x + integer :: incx + real :: beta + real dimension(*) :: y + integer :: incy + end subroutine sspmv + subroutine sspr(uplo,n,alpha,x,incx,ap) + character :: uplo + integer :: n + real :: alpha + real dimension(*) :: x + integer :: incx + real dimension(*) :: ap + end subroutine sspr + subroutine sspr2(uplo,n,alpha,x,incx,y,incy,ap) + character :: uplo + integer :: n + real :: alpha + real dimension(*) :: x + integer :: incx + real dimension(*) :: y + integer :: incy + real dimension(*) :: ap + end subroutine sspr2 + subroutine sswap(n,sx,incx,sy,incy) + integer :: n + real dimension(*) :: sx + integer :: incx + real dimension(*) :: sy + integer :: incy + end subroutine sswap + subroutine ssymm(side,uplo,m,n,alpha,a,lda,b,ldb,beta,c,ldc) + character :: side + character :: uplo + integer :: m + integer :: n + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + real :: beta + real dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine ssymm + subroutine ssymv(uplo,n,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + real :: beta + real dimension(*) :: y + integer :: incy + end subroutine ssymv + subroutine ssyr(uplo,n,alpha,x,incx,a,lda) + character :: uplo + integer :: n + real :: alpha + real dimension(*) :: x + integer :: incx + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine ssyr + subroutine ssyr2(uplo,n,alpha,x,incx,y,incy,a,lda) + character :: uplo + integer :: n + real :: alpha + real dimension(*) :: x + integer :: incx + real dimension(*) :: y + integer :: incy + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine ssyr2 + subroutine ssyr2k(uplo,trans,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + real :: beta + real dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine ssyr2k + subroutine ssyrk(uplo,trans,n,k,alpha,a,lda,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real :: beta + real dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine ssyrk + subroutine stbmv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + end subroutine stbmv + subroutine stbsv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + end subroutine stbsv + subroutine stpmv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + real dimension(*) :: ap + real dimension(*) :: x + integer :: incx + end subroutine stpmv + subroutine stpsv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + real dimension(*) :: ap + real dimension(*) :: x + integer :: incx + end subroutine stpsv + subroutine strmm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine strmm + subroutine strmv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + end subroutine strmv + subroutine strsm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + real :: alpha + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine strsm + subroutine strsv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + real dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + real dimension(*) :: x + integer :: incx + end subroutine strsv + subroutine xerbla(srname,info) + character*(*) :: srname + integer :: info + end subroutine xerbla + subroutine xerbla_array(srname_array,srname_len,info) + character(len=1) dimension(srname_len) :: srname_array + integer, optional,check(shape(srname_array, 0) == srname_len),depend(srname_array) :: srname_len=shape(srname_array, 0) + integer :: info + end subroutine xerbla_array + subroutine zaxpy(n,za,zx,incx,zy,incy) + integer :: n + complex*16 :: za + complex*16 dimension(*) :: zx + integer :: incx + complex*16 dimension(*) :: zy + integer :: incy + end subroutine zaxpy + subroutine zcopy(n,zx,incx,zy,incy) + integer :: n + complex*16 dimension(*) :: zx + integer :: incx + complex*16 dimension(*) :: zy + integer :: incy + end subroutine zcopy + function zdotc(n,zx,incx,zy,incy) + integer :: n + complex*16 dimension(*) :: zx + integer :: incx + complex*16 dimension(*) :: zy + integer :: incy + complex*16 :: zdotc + end function zdotc + function zdotu(n,zx,incx,zy,incy) + integer :: n + complex*16 dimension(*) :: zx + integer :: incx + complex*16 dimension(*) :: zy + integer :: incy + complex*16 :: zdotu + end function zdotu + subroutine zdrot(n,zx,incx,zy,incy,c,s) + integer :: n + complex*16 dimension(*) :: zx + integer :: incx + complex*16 dimension(*) :: zy + integer :: incy + double precision :: c + double precision :: s + end subroutine zdrot + subroutine zdscal(n,da,zx,incx) + integer :: n + double precision :: da + complex*16 dimension(*) :: zx + integer :: incx + end subroutine zdscal + subroutine zgbmv(trans,m,n,kl,ku,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + integer :: kl + integer :: ku + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + complex*16 :: beta + complex*16 dimension(*) :: y + integer :: incy + end subroutine zgbmv + subroutine zgemm(transa,transb,m,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: transa + character :: transb + integer :: m + integer :: n + integer :: k + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex*16 :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zgemm + subroutine zgemmtr(uplo,transa,transb,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: transa + character :: transb + integer :: n + integer :: k + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex*16 :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zgemmtr + subroutine zgemv(trans,m,n,alpha,a,lda,x,incx,beta,y,incy) + character :: trans + integer :: m + integer :: n + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + complex*16 :: beta + complex*16 dimension(*) :: y + integer :: incy + end subroutine zgemv + subroutine zgerc(m,n,alpha,x,incx,y,incy,a,lda) + integer :: m + integer :: n + complex*16 :: alpha + complex*16 dimension(*) :: x + integer :: incx + complex*16 dimension(*) :: y + integer :: incy + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine zgerc + subroutine zgeru(m,n,alpha,x,incx,y,incy,a,lda) + integer :: m + integer :: n + complex*16 :: alpha + complex*16 dimension(*) :: x + integer :: incx + complex*16 dimension(*) :: y + integer :: incy + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine zgeru + subroutine zhbmv(uplo,n,k,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + integer :: k + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + complex*16 :: beta + complex*16 dimension(*) :: y + integer :: incy + end subroutine zhbmv + subroutine zhemm(side,uplo,m,n,alpha,a,lda,b,ldb,beta,c,ldc) + character :: side + character :: uplo + integer :: m + integer :: n + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex*16 :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zhemm + subroutine zhemv(uplo,n,alpha,a,lda,x,incx,beta,y,incy) + character :: uplo + integer :: n + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + complex*16 :: beta + complex*16 dimension(*) :: y + integer :: incy + end subroutine zhemv + subroutine zher(uplo,n,alpha,x,incx,a,lda) + character :: uplo + integer :: n + double precision :: alpha + complex*16 dimension(*) :: x + integer :: incx + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine zher + subroutine zher2(uplo,n,alpha,x,incx,y,incy,a,lda) + character :: uplo + integer :: n + complex*16 :: alpha + complex*16 dimension(*) :: x + integer :: incx + complex*16 dimension(*) :: y + integer :: incy + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + end subroutine zher2 + subroutine zher2k(uplo,trans,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zher2k + subroutine zherk(uplo,trans,n,k,alpha,a,lda,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + double precision :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zherk + subroutine zhpmv(uplo,n,alpha,ap,x,incx,beta,y,incy) + character :: uplo + integer :: n + complex*16 :: alpha + complex*16 dimension(*) :: ap + complex*16 dimension(*) :: x + integer :: incx + complex*16 :: beta + complex*16 dimension(*) :: y + integer :: incy + end subroutine zhpmv + subroutine zhpr(uplo,n,alpha,x,incx,ap) + character :: uplo + integer :: n + double precision :: alpha + complex*16 dimension(*) :: x + integer :: incx + complex*16 dimension(*) :: ap + end subroutine zhpr + subroutine zhpr2(uplo,n,alpha,x,incx,y,incy,ap) + character :: uplo + integer :: n + complex*16 :: alpha + complex*16 dimension(*) :: x + integer :: incx + complex*16 dimension(*) :: y + integer :: incy + complex*16 dimension(*) :: ap + end subroutine zhpr2 + subroutine zrotg(a,b,c,s) + complex(kind=8) intent(inout) :: a + complex(kind=8) :: b + real(kind=8) intent(inout) :: c + complex(kind=8) intent(inout) :: s + end subroutine zrotg + subroutine zscal(n,za,zx,incx) + integer :: n + complex*16 :: za + complex*16 dimension(*) :: zx + integer :: incx + end subroutine zscal + subroutine zswap(n,zx,incx,zy,incy) + integer :: n + complex*16 dimension(*) :: zx + integer :: incx + complex*16 dimension(*) :: zy + integer :: incy + end subroutine zswap + subroutine zsymm(side,uplo,m,n,alpha,a,lda,b,ldb,beta,c,ldc) + character :: side + character :: uplo + integer :: m + integer :: n + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex*16 :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zsymm + subroutine zsyr2k(uplo,trans,n,k,alpha,a,lda,b,ldb,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + complex*16 :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zsyr2k + subroutine zsyrk(uplo,trans,n,k,alpha,a,lda,beta,c,ldc) + character :: uplo + character :: trans + integer :: n + integer :: k + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 :: beta + complex*16 dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + end subroutine zsyrk + subroutine ztbmv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + end subroutine ztbmv + subroutine ztbsv(uplo,trans,diag,n,k,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: k + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + end subroutine ztbsv + subroutine ztpmv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex*16 dimension(*) :: ap + complex*16 dimension(*) :: x + integer :: incx + end subroutine ztpmv + subroutine ztpsv(uplo,trans,diag,n,ap,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex*16 dimension(*) :: ap + complex*16 dimension(*) :: x + integer :: incx + end subroutine ztpsv + subroutine ztrmm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine ztrmm + subroutine ztrmv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + end subroutine ztrmv + subroutine ztrsm(side,uplo,transa,diag,m,n,alpha,a,lda,b,ldb) + character :: side + character :: uplo + character :: transa + character :: diag + integer :: m + integer :: n + complex*16 :: alpha + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine ztrsm + subroutine ztrsv(uplo,trans,diag,n,a,lda,x,incx) + character :: uplo + character :: trans + character :: diag + integer :: n + complex*16 dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + complex*16 dimension(*) :: x + integer :: incx + end subroutine ztrsv + end interface +end python module f2py_reference_blas + +! This file was auto-generated with f2py (version:2.5.1). +! See: +! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e diff --git a/examples/blas/build_all.sh b/examples/blas/build_all.sh new file mode 100644 index 000000000..ced6adc4f --- /dev/null +++ b/examples/blas/build_all.sh @@ -0,0 +1,4 @@ +source examples/blas/build_prik.sh +source "$EXAMPLE_WORKSPACE/examples/blas/build_f2py.sh" +cd "$EXAMPLE_WORKSPACE" +export PYTHONPATH="$BLAS_BUILD_ROOT/prik:$BLAS_F2PY_ROOT${PYTHONPATH:+:$PYTHONPATH}" diff --git a/examples/blas/build_f2py.sh b/examples/blas/build_f2py.sh new file mode 100644 index 000000000..834582305 --- /dev/null +++ b/examples/blas/build_f2py.sh @@ -0,0 +1,20 @@ +cd "$EXAMPLE_WORKSPACE" +export BLAS_F2PY_ROOT="$BLAS_BUILD_ROOT/f2py" +mkdir -p "$BLAS_F2PY_ROOT/generated" +cd "$BLAS_F2PY_ROOT" + +export FC="$(command -v gfortran)" +export F77="$FC" +export F90="$FC" +export FFLAGS="-O0" +export F90FLAGS="-O0" +export LDFLAGS="${LDFLAGS:+$LDFLAGS }-Wl,-rpath,$(dirname "$BLAS_SHARED_LIBRARY")" + +python -m numpy.f2py -c \ + "$EXAMPLE_WORKSPACE/examples/blas/blas.pyf" \ + "-L$(dirname "$BLAS_SHARED_LIBRARY")" \ + -lprik_full_blas \ + --build-dir "$BLAS_F2PY_ROOT/generated" \ + --f77flags=-O0 \ + --f90flags=-O0 \ + --opt=-O0 diff --git a/examples/blas/build_prik.sh b/examples/blas/build_prik.sh new file mode 100644 index 000000000..e303b13fc --- /dev/null +++ b/examples/blas/build_prik.sh @@ -0,0 +1,20 @@ +export EXAMPLE_WORKSPACE="$PWD" +export BLAS_BUILD_ROOT="$(mktemp -d)" +export BLAS_SHARED_LIBRARY="$( + python -m examples.native_library blas \ + --compiler "$(command -v gfortran)" \ + --jobs 8 +)" + +mkdir -p "$BLAS_BUILD_ROOT/prik/generated" +cd "$BLAS_BUILD_ROOT/prik" + +python -m prik "$EXAMPLE_WORKSPACE/examples/blas/native" \ + --out prik_reference_blas \ + --out-dir "$BLAS_BUILD_ROOT/prik/generated" \ + --compiler "$(command -v gfortran)" \ + --no-compile-input-sources \ + --native-objects "$BLAS_SHARED_LIBRARY" \ + --jobs 8 \ + --wrapper-fortran-flags="-O0 -g0" \ + --wrapper-c-flags="-O0 -g0" diff --git a/examples/blas/ci/__init__.py b/examples/blas/ci/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/blas/ci/full_surface.py b/examples/blas/ci/full_surface.py new file mode 100644 index 000000000..b991306a2 --- /dev/null +++ b/examples/blas/ci/full_surface.py @@ -0,0 +1,17 @@ +"""Maintainer-only complete-surface checks that reuse the BLAS example build.""" + +from __future__ import annotations + +import pytest + +from examples.blas.routine_inventory import ALL_ROUTINES +from examples.blas.tests.helpers import assert_runtime_smoke + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_ci_complete_prik_surface_reuses_example_extension(prik_blas): + missing = sorted(routine for routine in ALL_ROUTINES if not callable(getattr(prik_blas, routine, None))) + assert missing == [] + assert_runtime_smoke(prik_blas) diff --git a/examples/blas/conftest.py b/examples/blas/conftest.py new file mode 100644 index 000000000..f0127737b --- /dev/null +++ b/examples/blas/conftest.py @@ -0,0 +1,17 @@ +"""Import fixtures for the wrappers produced by ``build_all.sh``.""" + +import importlib + +import pytest + + +@pytest.fixture(scope="session") +def prik_blas(): + """Return the already-built PRIK BLAS module.""" + return importlib.import_module("prik_reference_blas") + + +@pytest.fixture(scope="session") +def f2py_blas(): + """Return the already-built f2py BLAS module.""" + return importlib.import_module("f2py_reference_blas") diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/caxpy.f b/examples/blas/native/caxpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/caxpy.f rename to examples/blas/native/caxpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ccopy.f b/examples/blas/native/ccopy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ccopy.f rename to examples/blas/native/ccopy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cdotc.f b/examples/blas/native/cdotc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cdotc.f rename to examples/blas/native/cdotc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cdotu.f b/examples/blas/native/cdotu.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cdotu.f rename to examples/blas/native/cdotu.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgbmv.f b/examples/blas/native/cgbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgbmv.f rename to examples/blas/native/cgbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgemm.f b/examples/blas/native/cgemm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgemm.f rename to examples/blas/native/cgemm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgemmtr.f b/examples/blas/native/cgemmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgemmtr.f rename to examples/blas/native/cgemmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgemv.f b/examples/blas/native/cgemv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgemv.f rename to examples/blas/native/cgemv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgerc.f b/examples/blas/native/cgerc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgerc.f rename to examples/blas/native/cgerc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgeru.f b/examples/blas/native/cgeru.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cgeru.f rename to examples/blas/native/cgeru.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chbmv.f b/examples/blas/native/chbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chbmv.f rename to examples/blas/native/chbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chemm.f b/examples/blas/native/chemm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chemm.f rename to examples/blas/native/chemm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chemv.f b/examples/blas/native/chemv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chemv.f rename to examples/blas/native/chemv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cher.f b/examples/blas/native/cher.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cher.f rename to examples/blas/native/cher.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cher2.f b/examples/blas/native/cher2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cher2.f rename to examples/blas/native/cher2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cher2k.f b/examples/blas/native/cher2k.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cher2k.f rename to examples/blas/native/cher2k.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cherk.f b/examples/blas/native/cherk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cherk.f rename to examples/blas/native/cherk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chpmv.f b/examples/blas/native/chpmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chpmv.f rename to examples/blas/native/chpmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chpr.f b/examples/blas/native/chpr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chpr.f rename to examples/blas/native/chpr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chpr2.f b/examples/blas/native/chpr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/chpr2.f rename to examples/blas/native/chpr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/crotg.f90 b/examples/blas/native/crotg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/crotg.f90 rename to examples/blas/native/crotg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cscal.f b/examples/blas/native/cscal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cscal.f rename to examples/blas/native/cscal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csrot.f b/examples/blas/native/csrot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csrot.f rename to examples/blas/native/csrot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csscal.f b/examples/blas/native/csscal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csscal.f rename to examples/blas/native/csscal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cswap.f b/examples/blas/native/cswap.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/cswap.f rename to examples/blas/native/cswap.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csymm.f b/examples/blas/native/csymm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csymm.f rename to examples/blas/native/csymm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csyr2k.f b/examples/blas/native/csyr2k.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csyr2k.f rename to examples/blas/native/csyr2k.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csyrk.f b/examples/blas/native/csyrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/csyrk.f rename to examples/blas/native/csyrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctbmv.f b/examples/blas/native/ctbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctbmv.f rename to examples/blas/native/ctbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctbsv.f b/examples/blas/native/ctbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctbsv.f rename to examples/blas/native/ctbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctpmv.f b/examples/blas/native/ctpmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctpmv.f rename to examples/blas/native/ctpmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctpsv.f b/examples/blas/native/ctpsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctpsv.f rename to examples/blas/native/ctpsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrmm.f b/examples/blas/native/ctrmm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrmm.f rename to examples/blas/native/ctrmm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrmv.f b/examples/blas/native/ctrmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrmv.f rename to examples/blas/native/ctrmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrsm.f b/examples/blas/native/ctrsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrsm.f rename to examples/blas/native/ctrsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrsv.f b/examples/blas/native/ctrsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ctrsv.f rename to examples/blas/native/ctrsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dasum.f b/examples/blas/native/dasum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dasum.f rename to examples/blas/native/dasum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/daxpy.f b/examples/blas/native/daxpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/daxpy.f rename to examples/blas/native/daxpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dcabs1.f b/examples/blas/native/dcabs1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dcabs1.f rename to examples/blas/native/dcabs1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dcopy.f b/examples/blas/native/dcopy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dcopy.f rename to examples/blas/native/dcopy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ddot.f b/examples/blas/native/ddot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ddot.f rename to examples/blas/native/ddot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgbmv.f b/examples/blas/native/dgbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgbmv.f rename to examples/blas/native/dgbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgemm.f b/examples/blas/native/dgemm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgemm.f rename to examples/blas/native/dgemm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgemmtr.f b/examples/blas/native/dgemmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgemmtr.f rename to examples/blas/native/dgemmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgemv.f b/examples/blas/native/dgemv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dgemv.f rename to examples/blas/native/dgemv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dger.f b/examples/blas/native/dger.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dger.f rename to examples/blas/native/dger.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dnrm2.f90 b/examples/blas/native/dnrm2.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dnrm2.f90 rename to examples/blas/native/dnrm2.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drot.f b/examples/blas/native/drot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drot.f rename to examples/blas/native/drot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drotg.f90 b/examples/blas/native/drotg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drotg.f90 rename to examples/blas/native/drotg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drotm.f b/examples/blas/native/drotm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drotm.f rename to examples/blas/native/drotm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drotmg.f b/examples/blas/native/drotmg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/drotmg.f rename to examples/blas/native/drotmg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsbmv.f b/examples/blas/native/dsbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsbmv.f rename to examples/blas/native/dsbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dscal.f b/examples/blas/native/dscal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dscal.f rename to examples/blas/native/dscal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsdot.f b/examples/blas/native/dsdot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsdot.f rename to examples/blas/native/dsdot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dspmv.f b/examples/blas/native/dspmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dspmv.f rename to examples/blas/native/dspmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dspr.f b/examples/blas/native/dspr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dspr.f rename to examples/blas/native/dspr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dspr2.f b/examples/blas/native/dspr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dspr2.f rename to examples/blas/native/dspr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dswap.f b/examples/blas/native/dswap.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dswap.f rename to examples/blas/native/dswap.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsymm.f b/examples/blas/native/dsymm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsymm.f rename to examples/blas/native/dsymm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsymv.f b/examples/blas/native/dsymv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsymv.f rename to examples/blas/native/dsymv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyr.f b/examples/blas/native/dsyr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyr.f rename to examples/blas/native/dsyr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyr2.f b/examples/blas/native/dsyr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyr2.f rename to examples/blas/native/dsyr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyr2k.f b/examples/blas/native/dsyr2k.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyr2k.f rename to examples/blas/native/dsyr2k.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyrk.f b/examples/blas/native/dsyrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dsyrk.f rename to examples/blas/native/dsyrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtbmv.f b/examples/blas/native/dtbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtbmv.f rename to examples/blas/native/dtbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtbsv.f b/examples/blas/native/dtbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtbsv.f rename to examples/blas/native/dtbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtpmv.f b/examples/blas/native/dtpmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtpmv.f rename to examples/blas/native/dtpmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtpsv.f b/examples/blas/native/dtpsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtpsv.f rename to examples/blas/native/dtpsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrmm.f b/examples/blas/native/dtrmm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrmm.f rename to examples/blas/native/dtrmm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrmv.f b/examples/blas/native/dtrmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrmv.f rename to examples/blas/native/dtrmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrsm.f b/examples/blas/native/dtrsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrsm.f rename to examples/blas/native/dtrsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrsv.f b/examples/blas/native/dtrsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dtrsv.f rename to examples/blas/native/dtrsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dzasum.f b/examples/blas/native/dzasum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dzasum.f rename to examples/blas/native/dzasum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dznrm2.f90 b/examples/blas/native/dznrm2.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/dznrm2.f90 rename to examples/blas/native/dznrm2.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/icamax.f b/examples/blas/native/icamax.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/icamax.f rename to examples/blas/native/icamax.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/idamax.f b/examples/blas/native/idamax.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/idamax.f rename to examples/blas/native/idamax.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/isamax.f b/examples/blas/native/isamax.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/isamax.f rename to examples/blas/native/isamax.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/izamax.f b/examples/blas/native/izamax.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/izamax.f rename to examples/blas/native/izamax.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/lsame.f b/examples/blas/native/lsame.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/lsame.f rename to examples/blas/native/lsame.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sasum.f b/examples/blas/native/sasum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sasum.f rename to examples/blas/native/sasum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/saxpy.f b/examples/blas/native/saxpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/saxpy.f rename to examples/blas/native/saxpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scabs1.f b/examples/blas/native/scabs1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scabs1.f rename to examples/blas/native/scabs1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scasum.f b/examples/blas/native/scasum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scasum.f rename to examples/blas/native/scasum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scnrm2.f90 b/examples/blas/native/scnrm2.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scnrm2.f90 rename to examples/blas/native/scnrm2.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scopy.f b/examples/blas/native/scopy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/scopy.f rename to examples/blas/native/scopy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sdot.f b/examples/blas/native/sdot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sdot.f rename to examples/blas/native/sdot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sdsdot.f b/examples/blas/native/sdsdot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sdsdot.f rename to examples/blas/native/sdsdot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgbmv.f b/examples/blas/native/sgbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgbmv.f rename to examples/blas/native/sgbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgemm.f b/examples/blas/native/sgemm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgemm.f rename to examples/blas/native/sgemm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgemmtr.f b/examples/blas/native/sgemmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgemmtr.f rename to examples/blas/native/sgemmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgemv.f b/examples/blas/native/sgemv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sgemv.f rename to examples/blas/native/sgemv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sger.f b/examples/blas/native/sger.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sger.f rename to examples/blas/native/sger.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/snrm2.f90 b/examples/blas/native/snrm2.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/snrm2.f90 rename to examples/blas/native/snrm2.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srot.f b/examples/blas/native/srot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srot.f rename to examples/blas/native/srot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srotg.f90 b/examples/blas/native/srotg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srotg.f90 rename to examples/blas/native/srotg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srotm.f b/examples/blas/native/srotm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srotm.f rename to examples/blas/native/srotm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srotmg.f b/examples/blas/native/srotmg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/srotmg.f rename to examples/blas/native/srotmg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssbmv.f b/examples/blas/native/ssbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssbmv.f rename to examples/blas/native/ssbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sscal.f b/examples/blas/native/sscal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sscal.f rename to examples/blas/native/sscal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sspmv.f b/examples/blas/native/sspmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sspmv.f rename to examples/blas/native/sspmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sspr.f b/examples/blas/native/sspr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sspr.f rename to examples/blas/native/sspr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sspr2.f b/examples/blas/native/sspr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sspr2.f rename to examples/blas/native/sspr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sswap.f b/examples/blas/native/sswap.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/sswap.f rename to examples/blas/native/sswap.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssymm.f b/examples/blas/native/ssymm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssymm.f rename to examples/blas/native/ssymm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssymv.f b/examples/blas/native/ssymv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssymv.f rename to examples/blas/native/ssymv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyr.f b/examples/blas/native/ssyr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyr.f rename to examples/blas/native/ssyr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyr2.f b/examples/blas/native/ssyr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyr2.f rename to examples/blas/native/ssyr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyr2k.f b/examples/blas/native/ssyr2k.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyr2k.f rename to examples/blas/native/ssyr2k.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyrk.f b/examples/blas/native/ssyrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ssyrk.f rename to examples/blas/native/ssyrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stbmv.f b/examples/blas/native/stbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stbmv.f rename to examples/blas/native/stbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stbsv.f b/examples/blas/native/stbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stbsv.f rename to examples/blas/native/stbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stpmv.f b/examples/blas/native/stpmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stpmv.f rename to examples/blas/native/stpmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stpsv.f b/examples/blas/native/stpsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/stpsv.f rename to examples/blas/native/stpsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strmm.f b/examples/blas/native/strmm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strmm.f rename to examples/blas/native/strmm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strmv.f b/examples/blas/native/strmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strmv.f rename to examples/blas/native/strmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strsm.f b/examples/blas/native/strsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strsm.f rename to examples/blas/native/strsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strsv.f b/examples/blas/native/strsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/strsv.f rename to examples/blas/native/strsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/xerbla.f b/examples/blas/native/xerbla.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/xerbla.f rename to examples/blas/native/xerbla.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/xerbla_array.f b/examples/blas/native/xerbla_array.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/xerbla_array.f rename to examples/blas/native/xerbla_array.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zaxpy.f b/examples/blas/native/zaxpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zaxpy.f rename to examples/blas/native/zaxpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zcopy.f b/examples/blas/native/zcopy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zcopy.f rename to examples/blas/native/zcopy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdotc.f b/examples/blas/native/zdotc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdotc.f rename to examples/blas/native/zdotc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdotu.f b/examples/blas/native/zdotu.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdotu.f rename to examples/blas/native/zdotu.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdrot.f b/examples/blas/native/zdrot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdrot.f rename to examples/blas/native/zdrot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdscal.f b/examples/blas/native/zdscal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zdscal.f rename to examples/blas/native/zdscal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgbmv.f b/examples/blas/native/zgbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgbmv.f rename to examples/blas/native/zgbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgemm.f b/examples/blas/native/zgemm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgemm.f rename to examples/blas/native/zgemm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgemmtr.f b/examples/blas/native/zgemmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgemmtr.f rename to examples/blas/native/zgemmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgemv.f b/examples/blas/native/zgemv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgemv.f rename to examples/blas/native/zgemv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgerc.f b/examples/blas/native/zgerc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgerc.f rename to examples/blas/native/zgerc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgeru.f b/examples/blas/native/zgeru.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zgeru.f rename to examples/blas/native/zgeru.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhbmv.f b/examples/blas/native/zhbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhbmv.f rename to examples/blas/native/zhbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhemm.f b/examples/blas/native/zhemm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhemm.f rename to examples/blas/native/zhemm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhemv.f b/examples/blas/native/zhemv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhemv.f rename to examples/blas/native/zhemv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zher.f b/examples/blas/native/zher.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zher.f rename to examples/blas/native/zher.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zher2.f b/examples/blas/native/zher2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zher2.f rename to examples/blas/native/zher2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zher2k.f b/examples/blas/native/zher2k.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zher2k.f rename to examples/blas/native/zher2k.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zherk.f b/examples/blas/native/zherk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zherk.f rename to examples/blas/native/zherk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhpmv.f b/examples/blas/native/zhpmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhpmv.f rename to examples/blas/native/zhpmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhpr.f b/examples/blas/native/zhpr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhpr.f rename to examples/blas/native/zhpr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhpr2.f b/examples/blas/native/zhpr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zhpr2.f rename to examples/blas/native/zhpr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zrotg.f90 b/examples/blas/native/zrotg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zrotg.f90 rename to examples/blas/native/zrotg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zscal.f b/examples/blas/native/zscal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zscal.f rename to examples/blas/native/zscal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zswap.f b/examples/blas/native/zswap.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zswap.f rename to examples/blas/native/zswap.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zsymm.f b/examples/blas/native/zsymm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zsymm.f rename to examples/blas/native/zsymm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zsyr2k.f b/examples/blas/native/zsyr2k.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zsyr2k.f rename to examples/blas/native/zsyr2k.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zsyrk.f b/examples/blas/native/zsyrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/zsyrk.f rename to examples/blas/native/zsyrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztbmv.f b/examples/blas/native/ztbmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztbmv.f rename to examples/blas/native/ztbmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztbsv.f b/examples/blas/native/ztbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztbsv.f rename to examples/blas/native/ztbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztpmv.f b/examples/blas/native/ztpmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztpmv.f rename to examples/blas/native/ztpmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztpsv.f b/examples/blas/native/ztpsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztpsv.f rename to examples/blas/native/ztpsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrmm.f b/examples/blas/native/ztrmm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrmm.f rename to examples/blas/native/ztrmm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrmv.f b/examples/blas/native/ztrmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrmv.f rename to examples/blas/native/ztrmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrsm.f b/examples/blas/native/ztrsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrsm.f rename to examples/blas/native/ztrsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrsv.f b/examples/blas/native/ztrsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/blas/native/ztrsv.f rename to examples/blas/native/ztrsv.f diff --git a/examples/blas/routine_inventory.py b/examples/blas/routine_inventory.py new file mode 100644 index 000000000..a949cfd8e --- /dev/null +++ b/examples/blas/routine_inventory.py @@ -0,0 +1,199 @@ +"""Authoritative classification and coverage expectations for reference BLAS.""" + +from __future__ import annotations + +ROUTINE_GROUPS: dict[str, tuple[str, ...]] = { + "BLAS Level 1 real": ( + "sasum", + "dasum", + "saxpy", + "daxpy", + "scopy", + "dcopy", + "sdot", + "ddot", + "sdsdot", + "dsdot", + "snrm2", + "dnrm2", + "srot", + "drot", + "srotg", + "drotg", + "srotm", + "drotm", + "srotmg", + "drotmg", + "sscal", + "dscal", + "sswap", + "dswap", + "isamax", + "idamax", + ), + "BLAS Level 1 complex": ( + "scasum", + "dzasum", + "caxpy", + "zaxpy", + "ccopy", + "zcopy", + "cdotc", + "zdotc", + "cdotu", + "zdotu", + "scnrm2", + "dznrm2", + "crotg", + "zrotg", + "cscal", + "zscal", + "csscal", + "zdscal", + "csrot", + "zdrot", + "cswap", + "zswap", + "icamax", + "izamax", + ), + "BLAS Level 2 general": ( + "sgemv", + "dgemv", + "cgemv", + "zgemv", + "sger", + "dger", + "cgeru", + "zgeru", + "cgerc", + "zgerc", + ), + "BLAS Level 2 symmetric": ( + "ssymv", + "dsymv", + "ssyr", + "dsyr", + "ssyr2", + "dsyr2", + ), + "BLAS Level 2 Hermitian": ( + "chemv", + "zhemv", + "cher", + "zher", + "cher2", + "zher2", + ), + "BLAS Level 2 triangular": ( + "strmv", + "dtrmv", + "ctrmv", + "ztrmv", + "strsv", + "dtrsv", + "ctrsv", + "ztrsv", + ), + "BLAS Level 2 packed": ( + "sspmv", + "dspmv", + "sspr", + "dspr", + "sspr2", + "dspr2", + "chpmv", + "zhpmv", + "chpr", + "zhpr", + "chpr2", + "zhpr2", + "stpmv", + "dtpmv", + "ctpmv", + "ztpmv", + "stpsv", + "dtpsv", + "ctpsv", + "ztpsv", + ), + "BLAS Level 2 banded": ( + "sgbmv", + "dgbmv", + "cgbmv", + "zgbmv", + "ssbmv", + "dsbmv", + "chbmv", + "zhbmv", + "stbmv", + "dtbmv", + "ctbmv", + "ztbmv", + "stbsv", + "dtbsv", + "ctbsv", + "ztbsv", + ), + "BLAS Level 3 general": ( + "sgemm", + "dgemm", + "cgemm", + "zgemm", + "sgemmtr", + "dgemmtr", + "cgemmtr", + "zgemmtr", + ), + "BLAS Level 3 symmetric": ( + "ssymm", + "dsymm", + "csymm", + "zsymm", + "ssyrk", + "dsyrk", + "csyrk", + "zsyrk", + "ssyr2k", + "dsyr2k", + "csyr2k", + "zsyr2k", + ), + "BLAS Level 3 Hermitian": ( + "chemm", + "zhemm", + "cherk", + "zherk", + "cher2k", + "zher2k", + ), + "BLAS Level 3 triangular": ( + "strmm", + "dtrmm", + "ctrmm", + "ztrmm", + "strsm", + "dtrsm", + "ctrsm", + "ztrsm", + ), + "Auxiliary and error reporting": ( + "scabs1", + "dcabs1", + "lsame", + "xerbla", + "xerbla_array", + ), +} + +ALL_ROUTINES = tuple(routine for routines in ROUTINE_GROUPS.values() for routine in routines) +PRIK_TESTED_ROUTINES = frozenset(ALL_ROUTINES) + +DIFFERENTIALLY_TESTED_ROUTINES = frozenset(ALL_ROUTINES) + +UNSUPPORTED_ROUTINES: dict[str, str] = {} +PERMANENTLY_SKIPPED_ROUTINES: dict[str, str] = {} + +EXPLICIT_TEST_NAMES = {routine: f"test_{routine}" for routine in ALL_ROUTINES} +EXPLICIT_TEST_NAMES["dgemv"] = "test_dgemv_no_transpose" +EXPLICIT_TEST_NAMES["dtrsv"] = "test_dtrsv_upper_nonunit" diff --git a/examples/blas/tests/__init__.py b/examples/blas/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/blas/tests/helpers.py b/examples/blas/tests/helpers.py new file mode 100644 index 000000000..6552c5fea --- /dev/null +++ b/examples/blas/tests/helpers.py @@ -0,0 +1,243 @@ +"""Small numerical and storage helpers used by the readable BLAS tests.""" + +from __future__ import annotations + +import numpy as np + + +def assert_allclose_for_dtype(actual, expected, *, operation_size: int = 1) -> None: + """Compare floating values with dtype- and accumulation-aware tolerances.""" + actual_array = np.asarray(actual) + expected_array = np.asarray(expected) + dtype = np.result_type(actual_array.dtype, expected_array.dtype) + real_dtype = np.empty((), dtype=dtype).real.dtype + epsilon = np.finfo(real_dtype).eps + scale = max(1, operation_size) + magnitude = max(1.0, float(np.max(np.abs(expected_array), initial=0.0))) + np.testing.assert_allclose( + actual_array, + expected_array, + rtol=epsilon * 8 * scale, + atol=epsilon * 8 * scale * magnitude, + ) + + +def logical_indices(n: int, increment: int) -> np.ndarray: + """Return zero-based storage positions visited by a native BLAS vector.""" + if n <= 0: + return np.array([], dtype=np.intp) + start = 0 if increment > 0 else (n - 1) * (-increment) + return start + np.arange(n, dtype=np.intp) * increment + + +def logical_vector(storage: np.ndarray, n: int, increment: int) -> np.ndarray: + """Copy the logical BLAS vector represented by storage and an increment.""" + return storage[logical_indices(n, increment)].copy() + + +def assert_storage_unchanged(actual: np.ndarray, original: np.ndarray) -> None: + """Require exact preservation, including NaNs and sentinel padding.""" + np.testing.assert_array_equal(actual, original, strict=True) + + +def with_logical_vector( + original: np.ndarray, + values: np.ndarray, + n: int, + increment: int, +) -> np.ndarray: + """Return storage with only the logical BLAS vector positions replaced.""" + expected = original.copy() + expected[logical_indices(n, increment)] = values + return expected + + +def symmetric_from_triangle(storage: np.ndarray, n: int, uplo: str) -> np.ndarray: + """Reconstruct a logical symmetric matrix without reading the unused triangle.""" + active = storage[:n, :n] + triangle = np.triu(active) if uplo.upper() == "U" else np.tril(active) + return triangle + triangle.T - np.diag(np.diag(triangle)) + + +def hermitian_from_triangle(storage: np.ndarray, n: int, uplo: str) -> np.ndarray: + """Reconstruct a Hermitian matrix and discard stored diagonal imaginary parts.""" + active = storage[:n, :n] + triangle = np.triu(active) if uplo.upper() == "U" else np.tril(active) + diagonal = np.diag(np.real(np.diag(triangle))).astype(storage.dtype) + return triangle + triangle.conj().T - np.diag(np.diag(triangle)) - np.diag(np.diag(triangle).conj()) + diagonal + + +def triangular_from_triangle( + storage: np.ndarray, + n: int, + uplo: str, + *, + unit_diagonal: bool, +) -> np.ndarray: + """Reconstruct a triangular matrix without inspecting unused or unit diagonal data.""" + active = storage[:n, :n] + if uplo.upper() == "U": + triangle = np.triu(active, k=1 if unit_diagonal else 0) + else: + triangle = np.tril(active, k=-1 if unit_diagonal else 0) + if unit_diagonal: + triangle = triangle + np.eye(n, dtype=storage.dtype) + return triangle + + +def packed_from_triangle(matrix: np.ndarray, uplo: str) -> np.ndarray: + """Pack one matrix triangle in the column-major BLAS packed format.""" + n = matrix.shape[0] + if uplo.upper() == "U": + values = [matrix[row, column] for column in range(n) for row in range(column + 1)] + else: + values = [matrix[row, column] for column in range(n) for row in range(column, n)] + return np.asarray(values, dtype=matrix.dtype) + + +def symmetric_from_packed(packed: np.ndarray, n: int, uplo: str) -> np.ndarray: + """Reconstruct a symmetric matrix from packed BLAS storage.""" + triangle = np.zeros((n, n), dtype=packed.dtype) + index = 0 + if uplo.upper() == "U": + for column in range(n): + for row in range(column + 1): + triangle[row, column] = packed[index] + index += 1 + else: + for column in range(n): + for row in range(column, n): + triangle[row, column] = packed[index] + index += 1 + return triangle + triangle.T - np.diag(np.diag(triangle)) + + +def hermitian_from_packed(packed: np.ndarray, n: int, uplo: str) -> np.ndarray: + """Reconstruct a Hermitian matrix from packed BLAS storage.""" + triangle = np.zeros((n, n), dtype=packed.dtype) + index = 0 + if uplo.upper() == "U": + for column in range(n): + for row in range(column + 1): + triangle[row, column] = packed[index] + index += 1 + else: + for column in range(n): + for row in range(column, n): + triangle[row, column] = packed[index] + index += 1 + diagonal = np.diag(np.real(np.diag(triangle))).astype(packed.dtype) + return triangle + triangle.conj().T - np.diag(np.diag(triangle)) - np.diag(np.diag(triangle).conj()) + diagonal + + +def triangular_from_packed( + packed: np.ndarray, + n: int, + uplo: str, + *, + unit_diagonal: bool, +) -> np.ndarray: + """Reconstruct a triangular matrix from packed BLAS storage.""" + triangle = np.zeros((n, n), dtype=packed.dtype) + index = 0 + if uplo.upper() == "U": + for column in range(n): + for row in range(column + 1): + if not unit_diagonal or row != column: + triangle[row, column] = packed[index] + index += 1 + else: + for column in range(n): + for row in range(column, n): + if not unit_diagonal or row != column: + triangle[row, column] = packed[index] + index += 1 + if unit_diagonal: + triangle += np.eye(n, dtype=packed.dtype) + return triangle + + +def general_from_band(storage: np.ndarray, m: int, n: int, kl: int, ku: int) -> np.ndarray: + """Reconstruct an m-by-n matrix from general band storage.""" + matrix = np.zeros((m, n), dtype=storage.dtype) + for column in range(n): + for row in range(max(0, column - ku), min(m, column + kl + 1)): + matrix[row, column] = storage[ku + row - column, column] + return matrix + + +def symmetric_from_band(storage: np.ndarray, n: int, k: int, uplo: str) -> np.ndarray: + """Reconstruct a symmetric matrix from symmetric band storage.""" + triangle = np.zeros((n, n), dtype=storage.dtype) + if uplo.upper() == "U": + for column in range(n): + for row in range(max(0, column - k), column + 1): + triangle[row, column] = storage[k + row - column, column] + else: + for column in range(n): + for row in range(column, min(n, column + k + 1)): + triangle[row, column] = storage[row - column, column] + return triangle + triangle.T - np.diag(np.diag(triangle)) + + +def hermitian_from_band(storage: np.ndarray, n: int, k: int, uplo: str) -> np.ndarray: + """Reconstruct a Hermitian matrix from Hermitian band storage.""" + triangle = np.zeros((n, n), dtype=storage.dtype) + if uplo.upper() == "U": + for column in range(n): + for row in range(max(0, column - k), column + 1): + triangle[row, column] = storage[k + row - column, column] + else: + for column in range(n): + for row in range(column, min(n, column + k + 1)): + triangle[row, column] = storage[row - column, column] + diagonal = np.diag(np.real(np.diag(triangle))).astype(storage.dtype) + return triangle + triangle.conj().T - np.diag(np.diag(triangle)) - np.diag(np.diag(triangle).conj()) + diagonal + + +def triangular_from_band( + storage: np.ndarray, + n: int, + k: int, + uplo: str, + *, + unit_diagonal: bool, +) -> np.ndarray: + """Reconstruct a triangular matrix from triangular band storage.""" + triangle = np.zeros((n, n), dtype=storage.dtype) + if uplo.upper() == "U": + for column in range(n): + for row in range(max(0, column - k), column + 1): + if not unit_diagonal or row != column: + triangle[row, column] = storage[k + row - column, column] + else: + for column in range(n): + for row in range(column, min(n, column + k + 1)): + if not unit_diagonal or row != column: + triangle[row, column] = storage[row - column, column] + if unit_diagonal: + triangle += np.eye(n, dtype=storage.dtype) + return triangle + + +def assert_runtime_smoke(module) -> None: + """Exercise representative complete-library BLAS exports.""" + x = np.array([1.0, 2.0, 3.0], dtype=np.float64) + y = np.array([10.0, 20.0, 30.0], dtype=np.float64) + daxpy_scalars = module.daxpy(np.int32(3), np.float64(2.0), x, np.int32(1), y, np.int32(1)) + assert daxpy_scalars == (np.int32(3), np.float64(2.0), np.int32(1), np.int32(1)) + np.testing.assert_allclose(y, [12.0, 24.0, 36.0]) + assert module.ddot(np.int32(3), x, np.int32(1), y, np.int32(1)) == ( + np.float64(168.0), + np.int32(3), + np.int32(1), + np.int32(1), + ) + assert module.dasum(np.int32(3), y, np.int32(1)) == ( + np.float64(72.0), + np.int32(3), + np.int32(1), + ) + dscal_scalars = module.dscal(np.int32(3), np.float64(0.5), y, np.int32(1)) + assert dscal_scalars == (np.int32(3), np.float64(0.5), np.int32(1)) + np.testing.assert_allclose(y, [6.0, 12.0, 18.0]) diff --git a/examples/blas/tests/test_auxiliary.py b/examples/blas/tests/test_auxiliary.py new file mode 100644 index 000000000..97250048d --- /dev/null +++ b/examples/blas/tests/test_auxiliary.py @@ -0,0 +1,149 @@ +"""Checks for the reference BLAS auxiliary and error-reporting routines.""" + +from __future__ import annotations + +import os +from pathlib import Path +import subprocess +import sys + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_scabs1(prik_blas, f2py_blas): + value = np.complex64(-3.0 + 4.0j) + + prik_result, prik_value = prik_blas.scabs1(value) + f2py_result = f2py_blas.scabs1(value) + + expected = np.float32(abs(value.real) + abs(value.imag)) + assert_allclose_for_dtype(prik_result, expected) + assert_allclose_for_dtype(f2py_result, expected) + assert_allclose_for_dtype(prik_result, f2py_result) + assert prik_value == value + assert prik_result.dtype == np.dtype(np.float32) + + +def test_dcabs1(prik_blas, f2py_blas): + value = np.complex128(-3.0 + 4.0j) + + prik_result, prik_value = prik_blas.dcabs1(value) + f2py_result = f2py_blas.dcabs1(value) + + expected = np.float64(abs(value.real) + abs(value.imag)) + assert_allclose_for_dtype(prik_result, expected) + assert_allclose_for_dtype(f2py_result, expected) + assert_allclose_for_dtype(prik_result, f2py_result) + assert prik_value == value + assert isinstance(prik_result, float) + + +def test_lsame(prik_blas, f2py_blas): + prik_equal = prik_blas.lsame("n", "N") + f2py_equal = f2py_blas.lsame(b"n", b"N") + prik_different = prik_blas.lsame("N", "T") + f2py_different = f2py_blas.lsame(b"N", b"T") + + assert prik_equal is True + assert f2py_equal == 1 + assert bool(prik_equal) == bool(f2py_equal) + assert prik_different is False + assert f2py_different == 0 + assert bool(prik_different) == bool(f2py_different) + + +def test_xerbla(prik_blas, f2py_blas): + prik_environment = dict(os.environ) + prik_environment["PYTHONPATH"] = os.pathsep.join( + filter(None, (str(Path(prik_blas.__file__).resolve().parent), prik_environment.get("PYTHONPATH"))) + ) + f2py_environment = dict(os.environ) + f2py_environment["PYTHONPATH"] = os.pathsep.join( + filter(None, (str(Path(f2py_blas.__file__).resolve().parent), f2py_environment.get("PYTHONPATH"))) + ) + + prik_result = subprocess.run( # nosec B603 - fixed interpreter and test program + ( + sys.executable, + "-c", + "import numpy as np, prik_reference_blas as blas; blas.xerbla('DTEST ', np.int32(3))", + ), + env=prik_environment, + capture_output=True, + text=True, + check=False, + ) + f2py_result = subprocess.run( # nosec B603 - fixed interpreter and test program + ( + sys.executable, + "-c", + "import numpy as np, f2py_reference_blas as blas; blas.xerbla(b'DTEST ', np.int32(3))", + ), + env=f2py_environment, + capture_output=True, + text=True, + check=False, + ) + + expected_message = "On entry to DTEST parameter number 3 had an illegal value" + assert prik_result.returncode == 0 + assert f2py_result.returncode == 0 + assert expected_message in prik_result.stdout + assert expected_message in f2py_result.stdout + assert prik_result.stdout == f2py_result.stdout + assert prik_result.stderr == "" + assert f2py_result.stderr == "" + + +def test_xerbla_array(prik_blas, f2py_blas): + prik_environment = dict(os.environ) + prik_environment["PYTHONPATH"] = os.pathsep.join( + filter(None, (str(Path(prik_blas.__file__).resolve().parent), prik_environment.get("PYTHONPATH"))) + ) + f2py_environment = dict(os.environ) + f2py_environment["PYTHONPATH"] = os.pathsep.join( + filter(None, (str(Path(f2py_blas.__file__).resolve().parent), f2py_environment.get("PYTHONPATH"))) + ) + + prik_result = subprocess.run( # nosec B603 - fixed interpreter and test program + ( + sys.executable, + "-c", + "import numpy as np, prik_reference_blas as blas; " + "name=np.frombuffer(b'DTEST ', dtype='S1').copy(); " + "blas.xerbla_array(name, np.int32(6), np.int32(4))", + ), + env=prik_environment, + capture_output=True, + text=True, + check=False, + ) + # f2py infers SRNAME_LEN and therefore exposes it as an optional keyword. + f2py_result = subprocess.run( # nosec B603 - fixed interpreter and test program + ( + sys.executable, + "-c", + "import numpy as np, f2py_reference_blas as blas; " + "name=np.frombuffer(b'DTEST ', dtype='S1').copy(); " + "blas.xerbla_array(name, np.int32(4), srname_len=np.int32(6))", + ), + env=f2py_environment, + capture_output=True, + text=True, + check=False, + ) + + expected_message = "On entry to DTEST parameter number 4 had an illegal value" + assert prik_result.returncode == 0 + assert f2py_result.returncode == 0 + assert expected_message in prik_result.stdout + assert expected_message in f2py_result.stdout + assert prik_result.stdout == f2py_result.stdout + assert prik_result.stderr == "" + assert f2py_result.stderr == "" diff --git a/examples/blas/tests/test_level1_complex.py b/examples/blas/tests/test_level1_complex.py new file mode 100644 index 000000000..7a4ba146e --- /dev/null +++ b/examples/blas/tests/test_level1_complex.py @@ -0,0 +1,416 @@ +"""Readable independent and differential checks for complex BLAS Level 1.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import ( + assert_allclose_for_dtype, + assert_storage_unchanged, + logical_vector, + with_logical_vector, +) + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_caxpy(prik_blas, f2py_blas): + alpha = np.complex64(1.5 - 0.5j) + x = np.array([1.0 + 2.0j, -2.0 + 1.0j, 0.5 - 3.0j], dtype=np.complex64) + original_y = np.array([3.0 - 1.0j, 2.0 + 4.0j, -5.0 + 0.5j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_scalars = prik_blas.caxpy(np.int32(3), alpha, prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_result = f2py_blas.caxpy(np.int32(3), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected_y = alpha * x + original_y + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert prik_scalars == (np.int32(3), alpha, np.int32(1), np.int32(1)) + assert f2py_result is None + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zaxpy(prik_blas, f2py_blas): + alpha = np.complex128(-0.25 + 2.0j) + x = np.array([2.0 - 1.0j, 3.0 + 0.5j, -1.0 + 4.0j], dtype=np.complex128) + original_y = np.array([1.0 + 3.0j, -2.0 + 1.0j, 5.0 - 0.5j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_scalars = prik_blas.zaxpy(np.int32(3), alpha, prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_result = f2py_blas.zaxpy(np.int32(3), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected_y = alpha * x + original_y + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert prik_scalars == (np.int32(3), alpha, np.int32(1), np.int32(1)) + assert f2py_result is None + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_scasum(prik_blas, f2py_blas): + x = np.array([1.0 - 2.0j, 90.0j, -3.0 + 4.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.scasum(np.int32(2), prik_x, np.int32(2)) + f2py_value = f2py_blas.scasum(np.int32(2), f2py_x, np.int32(2)) + + expected = np.float32(1.0 + 2.0 + 3.0 + 4.0) + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dzasum(prik_blas, f2py_blas): + x = np.array([1.5 - 2.5j, -3.0 + 4.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.dzasum(np.int32(2), prik_x, np.int32(1)) + f2py_value = f2py_blas.dzasum(np.int32(2), f2py_x, np.int32(1)) + + expected = np.float64(1.5 + 2.5 + 3.0 + 4.0) + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_ccopy(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, 90.0j, -3.0 + 4.0j], dtype=np.complex64) + original_y = np.array([5.0 - 1.0j, 80.0j, 6.0 + 2.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.ccopy(np.int32(2), prik_x, np.int32(2), prik_y, np.int32(2)) + f2py_blas.ccopy(np.int32(2), f2py_x, np.int32(2), f2py_y, np.int32(2)) + + expected_y = with_logical_vector(original_y, logical_vector(x, 2, 2), 2, 2) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zcopy(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, -3.0 + 4.0j], dtype=np.complex128) + original_y = np.array([5.0 - 1.0j, 6.0 + 2.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.zcopy(np.int32(2), prik_x, np.int32(-1), prik_y, np.int32(1)) + f2py_blas.zcopy(np.int32(2), f2py_x, np.int32(-1), f2py_y, np.int32(1)) + + expected_y = x[::-1] + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_cdotc(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, -3.0 + 1.0j], dtype=np.complex64) + y = np.array([2.0 - 1.0j, 4.0 + 3.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, *_ = prik_blas.cdotc(np.int32(2), prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_value = f2py_blas.cdotc(np.int32(2), f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected = np.conj(x[0]) * y[0] + np.conj(x[1]) * y[1] + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_zdotc(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, 90.0j, -3.0 + 1.0j], dtype=np.complex128) + y = np.array([2.0 - 1.0j, 4.0 + 3.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, *_ = prik_blas.zdotc(np.int32(2), prik_x, np.int32(2), prik_y, np.int32(1)) + f2py_value = f2py_blas.zdotc(np.int32(2), f2py_x, np.int32(2), f2py_y, np.int32(1)) + + expected = np.conj(x[0]) * y[0] + np.conj(x[2]) * y[1] + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_cdotu(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, -3.0 + 1.0j], dtype=np.complex64) + y = np.array([2.0 - 1.0j, 4.0 + 3.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, *_ = prik_blas.cdotu(np.int32(2), prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_value = f2py_blas.cdotu(np.int32(2), f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected = x[0] * y[0] + x[1] * y[1] + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_zdotu(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, -3.0 + 1.0j], dtype=np.complex128) + y = np.array([2.0 - 1.0j, 4.0 + 3.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, *_ = prik_blas.zdotu(np.int32(2), prik_x, np.int32(-1), prik_y, np.int32(1)) + f2py_value = f2py_blas.zdotu(np.int32(2), f2py_x, np.int32(-1), f2py_y, np.int32(1)) + + expected = x[1] * y[0] + x[0] * y[1] + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_scnrm2(prik_blas, f2py_blas): + x = np.array([3.0 + 0.0j, 90.0j, 0.0 + 4.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.scnrm2(np.int32(2), prik_x, np.int32(2)) + f2py_value = f2py_blas.scnrm2(np.int32(2), f2py_x, np.int32(2)) + + expected = np.float32(np.sqrt(3.0**2 + 4.0**2)) + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dznrm2(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, -3.0 + 4.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.dznrm2(np.int32(2), prik_x, np.int32(1)) + f2py_value = f2py_blas.dznrm2(np.int32(2), f2py_x, np.int32(1)) + + expected = np.float64(np.sqrt(1.0**2 + 2.0**2 + 3.0**2 + 4.0**2)) + assert_allclose_for_dtype(prik_value, expected, operation_size=4) + assert_allclose_for_dtype(f2py_value, expected, operation_size=4) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=4) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_crotg(prik_blas, f2py_blas): + a, b = np.complex64(3.0 + 1.0j), np.complex64(4.0 - 2.0j) + f2py_a = np.array(a, dtype=np.complex64) + f2py_b = np.array(b, dtype=np.complex64) + f2py_c = np.array(0.0, dtype=np.float32) + f2py_s = np.array(0.0j, dtype=np.complex64) + + result, prik_b, c, s = prik_blas.crotg(a, b, np.float32(0.0), np.complex64(0.0j)) + f2py_result = f2py_blas.crotg(f2py_a, f2py_b, f2py_c, f2py_s) + + assert_allclose_for_dtype(c * a + s * b, result, operation_size=2) + assert_allclose_for_dtype(-np.conj(s) * a + c * b, np.complex64(0.0j), operation_size=2) + assert_allclose_for_dtype(c * c + abs(s) ** 2, np.float32(1.0), operation_size=2) + assert_allclose_for_dtype([f2py_a, f2py_b, f2py_c, f2py_s], [result, prik_b, c, s]) + assert f2py_result is None + + +def test_zrotg(prik_blas, f2py_blas): + a, b = np.complex128(3.0 + 1.0j), np.complex128(4.0 - 2.0j) + f2py_a = np.array(a, dtype=np.complex128) + f2py_b = np.array(b, dtype=np.complex128) + f2py_c = np.array(0.0, dtype=np.float64) + f2py_s = np.array(0.0j, dtype=np.complex128) + + result, prik_b, c, s = prik_blas.zrotg(a, b, np.float64(0.0), np.complex128(0.0j)) + f2py_result = f2py_blas.zrotg(f2py_a, f2py_b, f2py_c, f2py_s) + + assert_allclose_for_dtype(c * a + s * b, result, operation_size=2) + assert_allclose_for_dtype(-np.conj(s) * a + c * b, np.complex128(0.0j), operation_size=2) + assert_allclose_for_dtype(c * c + abs(s) ** 2, np.float64(1.0), operation_size=2) + assert_allclose_for_dtype([f2py_a, f2py_b, f2py_c, f2py_s], [result, prik_b, c, s]) + assert f2py_result is None + + +def test_cscal(prik_blas, f2py_blas): + alpha = np.complex64(1.0 - 2.0j) + original = np.array([2.0 + 1.0j, -3.0 + 4.0j], dtype=np.complex64) + prik_x, f2py_x = original.copy(), original.copy() + + prik_blas.cscal(np.int32(2), alpha, prik_x, np.int32(1)) + f2py_blas.cscal(np.int32(2), alpha, f2py_x, np.int32(1)) + + expected = alpha * original + assert_allclose_for_dtype(prik_x, expected) + assert_allclose_for_dtype(f2py_x, expected) + assert_allclose_for_dtype(prik_x, f2py_x) + + +def test_zscal(prik_blas, f2py_blas): + alpha = np.complex128(-0.5 + 1.5j) + original = np.array([2.0 + 1.0j, 90.0j, -3.0 + 4.0j], dtype=np.complex128) + prik_x, f2py_x = original.copy(), original.copy() + + prik_blas.zscal(np.int32(2), alpha, prik_x, np.int32(2)) + f2py_blas.zscal(np.int32(2), alpha, f2py_x, np.int32(2)) + + expected = with_logical_vector(original, alpha * original[::2], 2, 2) + assert_allclose_for_dtype(prik_x, expected) + assert_allclose_for_dtype(f2py_x, expected) + assert_allclose_for_dtype(prik_x, f2py_x) + + +def test_csscal(prik_blas, f2py_blas): + alpha = np.float32(-2.0) + original = np.array([2.0 + 1.0j, -3.0 + 4.0j], dtype=np.complex64) + prik_x, f2py_x = original.copy(), original.copy() + + prik_blas.csscal(np.int32(2), alpha, prik_x, np.int32(1)) + f2py_blas.csscal(np.int32(2), alpha, f2py_x, np.int32(1)) + + expected = alpha * original + assert_allclose_for_dtype(prik_x, expected) + assert_allclose_for_dtype(f2py_x, expected) + assert_allclose_for_dtype(prik_x, f2py_x) + + +def test_zdscal(prik_blas, f2py_blas): + alpha = np.float64(0.25) + original = np.array([2.0 + 1.0j, -3.0 + 4.0j], dtype=np.complex128) + prik_x, f2py_x = original.copy(), original.copy() + + prik_blas.zdscal(np.int32(2), alpha, prik_x, np.int32(1)) + f2py_blas.zdscal(np.int32(2), alpha, f2py_x, np.int32(1)) + + expected = alpha * original + assert_allclose_for_dtype(prik_x, expected) + assert_allclose_for_dtype(f2py_x, expected) + assert_allclose_for_dtype(prik_x, f2py_x) + + +def test_csrot(prik_blas, f2py_blas): + c, s = np.float32(0.6), np.float32(0.8) + x = np.array([1.0 + 2.0j, -2.0 + 1.0j], dtype=np.complex64) + y = np.array([3.0 - 1.0j, 4.0 + 2.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.csrot(np.int32(2), prik_x, np.int32(1), prik_y, np.int32(1), c, s) + f2py_blas.csrot(np.int32(2), f2py_x, np.int32(1), f2py_y, np.int32(1), c, s) + + expected_x = c * x + s * y + expected_y = c * y - s * x + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + + +def test_zdrot(prik_blas, f2py_blas): + c, s = np.float64(0.8), np.float64(-0.6) + x = np.array([1.0 + 2.0j, -2.0 + 1.0j], dtype=np.complex128) + y = np.array([3.0 - 1.0j, 4.0 + 2.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.zdrot(np.int32(2), prik_x, np.int32(1), prik_y, np.int32(1), c, s) + f2py_blas.zdrot(np.int32(2), f2py_x, np.int32(1), f2py_y, np.int32(1), c, s) + + expected_x = c * x + s * y + expected_y = c * y - s * x + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + + +def test_cswap(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, 90.0j, -2.0 + 1.0j], dtype=np.complex64) + y = np.array([3.0 - 1.0j, 80.0j, 4.0 + 2.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.cswap(np.int32(2), prik_x, np.int32(2), prik_y, np.int32(2)) + f2py_blas.cswap(np.int32(2), f2py_x, np.int32(2), f2py_y, np.int32(2)) + + expected_x = with_logical_vector(x, y[::2], 2, 2) + expected_y = with_logical_vector(y, x[::2], 2, 2) + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + + +def test_zswap(prik_blas, f2py_blas): + x = np.array([1.0 + 2.0j, -2.0 + 1.0j], dtype=np.complex128) + y = np.array([3.0 - 1.0j, 4.0 + 2.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.zswap(np.int32(2), prik_x, np.int32(-1), prik_y, np.int32(1)) + f2py_blas.zswap(np.int32(2), f2py_x, np.int32(-1), f2py_y, np.int32(1)) + + expected_x = y[::-1] + expected_y = x[::-1] + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + + +def test_icamax(prik_blas, f2py_blas): + x = np.array([1.0 + 1.0j, -4.0 + 5.0j, 3.0 - 2.0j], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + + prik_index, *_ = prik_blas.icamax(np.int32(3), prik_x, np.int32(1)) + f2py_index = f2py_blas.icamax(np.int32(3), f2py_x, np.int32(1)) + + expected_native_one_based_index = 2 + assert prik_index == expected_native_one_based_index + assert f2py_index == expected_native_one_based_index + assert prik_index == f2py_index + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_izamax(prik_blas, f2py_blas): + x = np.array([1.0 + 1.0j, 90.0j, -4.0 + 5.0j, 80.0j, 3.0 - 2.0j], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + + prik_index, *_ = prik_blas.izamax(np.int32(3), prik_x, np.int32(2)) + f2py_index = f2py_blas.izamax(np.int32(3), f2py_x, np.int32(2)) + + expected_native_one_based_index = 2 + assert prik_index == expected_native_one_based_index + assert f2py_index == expected_native_one_based_index + assert prik_index == f2py_index + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) diff --git a/examples/blas/tests/test_level1_real.py b/examples/blas/tests/test_level1_real.py new file mode 100644 index 000000000..cb6429503 --- /dev/null +++ b/examples/blas/tests/test_level1_real.py @@ -0,0 +1,499 @@ +"""Readable independent and differential checks for real BLAS Level 1.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import ( + assert_allclose_for_dtype, + assert_storage_unchanged, + logical_vector, + with_logical_vector, +) + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_saxpy(prik_blas, f2py_blas): + alpha = np.float32(2.5) + x = np.array([1.0, -2.0, 3.0], dtype=np.float32) + original_y = np.array([10.0, 20.0, -5.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_scalars = prik_blas.saxpy(np.int32(3), alpha, prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_result = f2py_blas.saxpy(np.int32(3), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected_y = alpha * x + original_y + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert prik_scalars == (np.int32(3), alpha, np.int32(1), np.int32(1)) + assert f2py_result is None + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_daxpy(prik_blas, f2py_blas): + alpha = np.float64(-1.5) + x = np.array([2.0, -4.0, 1.0], dtype=np.float64) + original_y = np.array([3.0, 5.0, -2.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_scalars = prik_blas.daxpy(np.int32(3), alpha, prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_result = f2py_blas.daxpy(np.int32(3), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected_y = alpha * x + original_y + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert prik_scalars == (np.int32(3), alpha, np.int32(1), np.int32(1)) + assert f2py_result is None + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_ddot(prik_blas, f2py_blas): + x = np.array([1.0, -2.0, 4.0], dtype=np.float64) + y = np.array([3.0, 5.0, -1.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, n, incx, incy = prik_blas.ddot(np.int32(3), prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_value = f2py_blas.ddot(np.int32(3), f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected = np.float64(1.0 * 3.0 + (-2.0) * 5.0 + 4.0 * (-1.0)) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert (n, incx, incy) == (np.int32(3), np.int32(1), np.int32(1)) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_sasum(prik_blas, f2py_blas): + x = np.array([-1.0, 99.0, 2.5, 98.0, -3.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.sasum(np.int32(3), prik_x, np.int32(2)) + f2py_value = f2py_blas.sasum(np.int32(3), f2py_x, np.int32(2)) + + expected = np.float32(abs(-1.0) + abs(2.5) + abs(-3.0)) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dasum(prik_blas, f2py_blas): + x = np.array([-1.5, 2.0, -4.25], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.dasum(np.int32(3), prik_x, np.int32(1)) + f2py_value = f2py_blas.dasum(np.int32(3), f2py_x, np.int32(1)) + + expected = np.float64(1.5 + 2.0 + 4.25) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_scopy(prik_blas, f2py_blas): + x = np.array([1.0, 90.0, 2.0, 91.0, 3.0], dtype=np.float32) + original_y = np.array([-1.0, 80.0, -2.0, 81.0, -3.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.scopy(np.int32(3), prik_x, np.int32(2), prik_y, np.int32(2)) + f2py_blas.scopy(np.int32(3), f2py_x, np.int32(2), f2py_y, np.int32(2)) + + expected_y = with_logical_vector(original_y, logical_vector(x, 3, 2), 3, 2) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dcopy(prik_blas, f2py_blas): + x = np.array([1.0, 2.0, 3.0], dtype=np.float64) + original_y = np.array([7.0, 8.0, 9.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.dcopy(np.int32(3), prik_x, np.int32(-1), prik_y, np.int32(1)) + f2py_blas.dcopy(np.int32(3), f2py_x, np.int32(-1), f2py_y, np.int32(1)) + + expected_y = np.array([3.0, 2.0, 1.0], dtype=np.float64) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_y, f2py_y) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_sdot(prik_blas, f2py_blas): + x = np.array([1.0, 99.0, -2.0, 98.0, 3.0], dtype=np.float32) + y = np.array([4.0, 5.0, -1.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, *_ = prik_blas.sdot(np.int32(3), prik_x, np.int32(2), prik_y, np.int32(1)) + f2py_value = f2py_blas.sdot(np.int32(3), f2py_x, np.int32(2), f2py_y, np.int32(1)) + + expected = np.float32(1.0 * 4.0 + (-2.0) * 5.0 + 3.0 * (-1.0)) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_sdsdot(prik_blas, f2py_blas): + bias = np.float32(1.25) + x = np.array([1.0, -2.0, 3.0], dtype=np.float32) + y = np.array([4.0, 0.5, -1.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, *_ = prik_blas.sdsdot(np.int32(3), bias, prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_value = f2py_blas.sdsdot(np.int32(3), bias, f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected = np.float32(np.float64(bias) + 1.0 * 4.0 + (-2.0) * 0.5 + 3.0 * (-1.0)) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_dsdot(prik_blas, f2py_blas): + x = np.array([1.0e10, 1.0, -1.0e10], dtype=np.float32) + y = np.ones(3, dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_value, *_ = prik_blas.dsdot(np.int32(3), prik_x, np.int32(1), prik_y, np.int32(1)) + f2py_value = f2py_blas.dsdot(np.int32(3), f2py_x, np.int32(1), f2py_y, np.int32(1)) + + expected = np.float64(np.float64(x[0]) + np.float64(x[1]) + np.float64(x[2])) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_snrm2(prik_blas, f2py_blas): + x = np.array([3.0, 99.0, 4.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.snrm2(np.int32(2), prik_x, np.int32(2)) + f2py_value = f2py_blas.snrm2(np.int32(2), f2py_x, np.int32(2)) + + expected = np.float32(np.sqrt(np.float32(3.0**2 + 4.0**2))) + assert_allclose_for_dtype(prik_value, expected, operation_size=2) + assert_allclose_for_dtype(f2py_value, expected, operation_size=2) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dnrm2(prik_blas, f2py_blas): + x = np.array([2.0, -3.0, 6.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + + prik_value, *_ = prik_blas.dnrm2(np.int32(3), prik_x, np.int32(1)) + f2py_value = f2py_blas.dnrm2(np.int32(3), f2py_x, np.int32(1)) + + expected = np.float64(np.sqrt(2.0**2 + (-3.0) ** 2 + 6.0**2)) + assert_allclose_for_dtype(prik_value, expected, operation_size=3) + assert_allclose_for_dtype(f2py_value, expected, operation_size=3) + assert_allclose_for_dtype(prik_value, f2py_value, operation_size=3) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_srot(prik_blas, f2py_blas): + c, s = np.float32(0.6), np.float32(0.8) + x = np.array([1.0, 2.0], dtype=np.float32) + y = np.array([3.0, 4.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.srot(np.int32(2), prik_x, np.int32(1), prik_y, np.int32(1), c, s) + f2py_blas.srot(np.int32(2), f2py_x, np.int32(1), f2py_y, np.int32(1), c, s) + + expected_x = c * x + s * y + expected_y = c * y - s * x + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_x, f2py_x) + assert_allclose_for_dtype(prik_y, f2py_y) + + +def test_drot(prik_blas, f2py_blas): + c, s = np.float64(0.8), np.float64(-0.6) + x = np.array([1.0, 90.0, 2.0], dtype=np.float64) + y = np.array([3.0, 80.0, 4.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.drot(np.int32(2), prik_x, np.int32(2), prik_y, np.int32(2), c, s) + f2py_blas.drot(np.int32(2), f2py_x, np.int32(2), f2py_y, np.int32(2), c, s) + + expected_x = with_logical_vector(x, c * x[::2] + s * y[::2], 2, 2) + expected_y = with_logical_vector(y, c * y[::2] - s * x[::2], 2, 2) + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + assert_allclose_for_dtype(prik_x, f2py_x) + assert_allclose_for_dtype(prik_y, f2py_y) + + +def test_srotg(prik_blas, f2py_blas): + a, b = np.float32(3.0), np.float32(4.0) + f2py_a = np.array(a, dtype=np.float32) + f2py_b = np.array(b, dtype=np.float32) + f2py_c = np.array(0.0, dtype=np.float32) + f2py_s = np.array(0.0, dtype=np.float32) + + prik_a, prik_b, c, s = prik_blas.srotg(a, b, np.float32(0.0), np.float32(0.0)) + f2py_result = f2py_blas.srotg(f2py_a, f2py_b, f2py_c, f2py_s) + + assert_allclose_for_dtype(prik_a, np.float32(5.0)) + assert_allclose_for_dtype(prik_b, np.float32(5.0 / 3.0)) + assert_allclose_for_dtype(c * a + s * b, prik_a, operation_size=2) + assert_allclose_for_dtype(-s * a + c * b, np.float32(0.0), operation_size=2) + assert_allclose_for_dtype([f2py_a, f2py_b, f2py_c, f2py_s], [prik_a, prik_b, c, s]) + assert f2py_result is None + + +def test_drotg(prik_blas, f2py_blas): + a, b = np.float64(3.0), np.float64(4.0) + f2py_a = np.array(a, dtype=np.float64) + f2py_b = np.array(b, dtype=np.float64) + f2py_c = np.array(0.0, dtype=np.float64) + f2py_s = np.array(0.0, dtype=np.float64) + + prik_a, prik_b, c, s = prik_blas.drotg(a, b, np.float64(0.0), np.float64(0.0)) + f2py_result = f2py_blas.drotg(f2py_a, f2py_b, f2py_c, f2py_s) + + assert_allclose_for_dtype(prik_a, np.float64(5.0)) + assert_allclose_for_dtype(prik_b, np.float64(5.0 / 3.0)) + assert_allclose_for_dtype(c * a + s * b, prik_a, operation_size=2) + assert_allclose_for_dtype(-s * a + c * b, np.float64(0.0), operation_size=2) + assert_allclose_for_dtype([f2py_a, f2py_b, f2py_c, f2py_s], [prik_a, prik_b, c, s]) + assert f2py_result is None + + +def test_srotm(prik_blas, f2py_blas): + x = np.array([1.0, 2.0], dtype=np.float32) + y = np.array([3.0, 4.0], dtype=np.float32) + param = np.array([-1.0, 2.0, 0.5, -0.25, 3.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_param, f2py_param = param.copy(), param.copy() + + prik_blas.srotm(np.int32(2), prik_x, np.int32(1), prik_y, np.int32(1), prik_param) + f2py_blas.srotm(np.int32(2), f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_param) + + expected_x = param[1] * x + param[3] * y + expected_y = param[2] * x + param[4] * y + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_storage_unchanged(prik_param, param) + assert_storage_unchanged(f2py_param, param) + + +def test_drotm(prik_blas, f2py_blas): + x = np.array([1.0, 2.0], dtype=np.float64) + y = np.array([3.0, 4.0], dtype=np.float64) + param = np.array([-1.0, 2.0, 0.5, -0.25, 3.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_param, f2py_param = param.copy(), param.copy() + + prik_blas.drotm(np.int32(2), prik_x, np.int32(1), prik_y, np.int32(1), prik_param) + f2py_blas.drotm(np.int32(2), f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_param) + + expected_x = param[1] * x + param[3] * y + expected_y = param[2] * x + param[4] * y + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_storage_unchanged(prik_param, param) + assert_storage_unchanged(f2py_param, param) + + +def test_srotmg(prik_blas, f2py_blas): + prik_param = np.zeros(5, dtype=np.float32) + f2py_param = np.zeros(5, dtype=np.float32) + f2py_scalars = [np.array(value, dtype=np.float32) for value in (1.0, 2.0, 3.0, 4.0)] + + prik_values = prik_blas.srotmg(np.float32(1.0), np.float32(2.0), np.float32(3.0), np.float32(4.0), prik_param) + f2py_result = f2py_blas.srotmg(*f2py_scalars, f2py_param) + + expected_values = np.array([1.5609756, 0.7804878, 5.125, 4.0], dtype=np.float32) + expected_param = np.array([1.0, 0.375, 0.0, 0.0, 0.75], dtype=np.float32) + assert_allclose_for_dtype(prik_values, expected_values, operation_size=2) + assert_allclose_for_dtype(f2py_scalars, expected_values, operation_size=2) + assert_allclose_for_dtype(f2py_scalars, prik_values, operation_size=2) + assert_allclose_for_dtype(prik_param, expected_param) + assert_allclose_for_dtype(f2py_param, expected_param) + assert_allclose_for_dtype(prik_param, f2py_param) + assert f2py_result is None + + +def test_drotmg(prik_blas, f2py_blas): + prik_param = np.zeros(5, dtype=np.float64) + f2py_param = np.zeros(5, dtype=np.float64) + f2py_scalars = [np.array(value, dtype=np.float64) for value in (1.0, 2.0, 3.0, 4.0)] + + prik_values = prik_blas.drotmg(np.float64(1.0), np.float64(2.0), np.float64(3.0), np.float64(4.0), prik_param) + f2py_result = f2py_blas.drotmg(*f2py_scalars, f2py_param) + + expected_values = np.array([1.5609756097560976, 0.7804878048780488, 5.125, 4.0]) + expected_param = np.array([1.0, 0.375, 0.0, 0.0, 0.75]) + assert_allclose_for_dtype(prik_values, expected_values, operation_size=2) + assert_allclose_for_dtype(f2py_scalars, expected_values, operation_size=2) + assert_allclose_for_dtype(f2py_scalars, prik_values, operation_size=2) + assert_allclose_for_dtype(prik_param, expected_param) + assert_allclose_for_dtype(f2py_param, expected_param) + assert_allclose_for_dtype(prik_param, f2py_param) + assert f2py_result is None + + +def test_sscal(prik_blas, f2py_blas): + alpha = np.float32(-2.0) + original = np.array([3.0], dtype=np.float32) + prik_x, f2py_x = original.copy(), original.copy() + + prik_blas.sscal(np.int32(1), alpha, prik_x, np.int32(1)) + f2py_blas.sscal(np.int32(1), alpha, f2py_x, np.int32(1)) + + expected = alpha * original + assert_allclose_for_dtype(prik_x, expected) + assert_allclose_for_dtype(f2py_x, expected) + assert_allclose_for_dtype(prik_x, f2py_x) + + +def test_dscal(prik_blas, f2py_blas): + alpha = np.float64(0.5) + original = np.array([2.0, 90.0, -4.0], dtype=np.float64) + prik_x, f2py_x = original.copy(), original.copy() + + prik_blas.dscal(np.int32(2), alpha, prik_x, np.int32(2)) + f2py_blas.dscal(np.int32(2), alpha, f2py_x, np.int32(2)) + + expected = with_logical_vector(original, alpha * original[::2], 2, 2) + assert_allclose_for_dtype(prik_x, expected) + assert_allclose_for_dtype(f2py_x, expected) + assert_allclose_for_dtype(prik_x, f2py_x) + + +def test_sswap(prik_blas, f2py_blas): + x = np.array([1.0, 90.0, 2.0], dtype=np.float32) + y = np.array([3.0, 80.0, 4.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.sswap(np.int32(2), prik_x, np.int32(2), prik_y, np.int32(2)) + f2py_blas.sswap(np.int32(2), f2py_x, np.int32(2), f2py_y, np.int32(2)) + + expected_x = with_logical_vector(x, y[::2], 2, 2) + expected_y = with_logical_vector(y, x[::2], 2, 2) + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + + +def test_dswap(prik_blas, f2py_blas): + x = np.array([1.0, 2.0, 3.0], dtype=np.float64) + y = np.array([4.0, 5.0, 6.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.dswap(np.int32(3), prik_x, np.int32(-1), prik_y, np.int32(1)) + f2py_blas.dswap(np.int32(3), f2py_x, np.int32(-1), f2py_y, np.int32(1)) + + expected_x = np.array([6.0, 5.0, 4.0]) + expected_y = np.array([3.0, 2.0, 1.0]) + assert_allclose_for_dtype(prik_x, expected_x) + assert_allclose_for_dtype(f2py_x, expected_x) + assert_allclose_for_dtype(prik_y, expected_y) + assert_allclose_for_dtype(f2py_y, expected_y) + + +def test_isamax(prik_blas, f2py_blas): + x = np.array([1.0, -7.0, 3.0], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + + prik_index, *_ = prik_blas.isamax(np.int32(3), prik_x, np.int32(1)) + f2py_index = f2py_blas.isamax(np.int32(3), f2py_x, np.int32(1)) + + expected_native_one_based_index = 2 + assert prik_index == expected_native_one_based_index + assert f2py_index == expected_native_one_based_index + assert prik_index == f2py_index + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_idamax(prik_blas, f2py_blas): + x = np.array([1.0, 90.0, -8.0, 91.0, 3.0], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + + prik_index, *_ = prik_blas.idamax(np.int32(3), prik_x, np.int32(2)) + f2py_index = f2py_blas.idamax(np.int32(3), f2py_x, np.int32(2)) + + expected_native_one_based_index = 2 + assert prik_index == expected_native_one_based_index + assert f2py_index == expected_native_one_based_index + assert prik_index == f2py_index + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_daxpy_alpha_zero_preserves_y(prik_blas, f2py_blas): + x = np.array([1.0, 2.0], dtype=np.float64) + original_y = np.array([3.0, 4.0], dtype=np.float64) + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.daxpy(np.int32(2), np.float64(0.0), x.copy(), np.int32(1), prik_y, np.int32(1)) + f2py_blas.daxpy(np.int32(2), np.float64(0.0), x.copy(), np.int32(1), f2py_y, np.int32(1)) + + assert_storage_unchanged(prik_y, original_y) + assert_storage_unchanged(f2py_y, original_y) + + +def test_sdot_empty_input(prik_blas, f2py_blas): + x = np.array([91.0], dtype=np.float32) + y = np.array([92.0], dtype=np.float32) + + prik_value, *_ = prik_blas.sdot(np.int32(0), x.copy(), np.int32(1), y.copy(), np.int32(1)) + f2py_value = f2py_blas.sdot(np.int32(0), x.copy(), np.int32(1), y.copy(), np.int32(1)) + + assert_allclose_for_dtype(prik_value, np.float32(0.0)) + assert_allclose_for_dtype(f2py_value, np.float32(0.0)) diff --git a/examples/blas/tests/test_level2_banded.py b/examples/blas/tests/test_level2_banded.py new file mode 100644 index 000000000..c17305a91 --- /dev/null +++ b/examples/blas/tests/test_level2_banded.py @@ -0,0 +1,493 @@ +"""Readable independent and differential checks for banded BLAS Level 2.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import ( + assert_allclose_for_dtype, + assert_storage_unchanged, + general_from_band, + hermitian_from_band, + symmetric_from_band, + triangular_from_band, +) + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_sgbmv(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + original_a = np.asfortranarray([[91.0, -1.0], [2.0, 3.0], [4.0, 92.0], [93.0, 94.0]], dtype=np.float32) + x = np.array([2.0, -3.0], dtype=np.float32) + original_y = np.array([4.0, 5.0], dtype=np.float32) + logical_a = general_from_band(original_a, 2, 2, 1, 1) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.sgbmv( + "N", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + prik_a, + np.int32(4), + prik_x, + np.int32(1), + beta, + prik_y, + np.int32(1), + ) + f2py_blas.sgbmv( + b"N", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + f2py_a, + f2py_x, + np.int32(1), + beta, + f2py_y, + np.int32(1), + lda=np.int32(4), + ) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dgbmv(prik_blas, f2py_blas): + alpha, beta = np.float64(-2.0), np.float64(1.0) + original_a = np.asfortranarray([[91.0, -1.0], [2.0, 3.0], [4.0, 92.0], [93.0, 94.0]], dtype=np.float64) + x = np.array([2.0, -3.0], dtype=np.float64) + original_y = np.array([4.0, 5.0], dtype=np.float64) + logical_a = general_from_band(original_a, 2, 2, 1, 1) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.dgbmv( + "T", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + prik_a, + np.int32(4), + prik_x, + np.int32(1), + beta, + prik_y, + np.int32(1), + ) + f2py_blas.dgbmv( + b"T", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + f2py_a, + f2py_x, + np.int32(1), + beta, + f2py_y, + np.int32(1), + lda=np.int32(4), + ) + + expected_y = alpha * logical_a.T @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_cgbmv(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + original_a = np.asfortranarray( + [[91.0j, -1.0 + 2.0j], [2.0 + 1.0j, 3.0 - 1.0j], [4.0 + 0.5j, 92.0j], [93.0j, 94.0j]], dtype=np.complex64 + ) + x = np.array([2.0 + 1.0j, -3.0 + 0.5j], dtype=np.complex64) + original_y = np.array([4.0 - 1.0j, 5.0 + 2.0j], dtype=np.complex64) + logical_a = general_from_band(original_a, 2, 2, 1, 1) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.cgbmv( + "N", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + prik_a, + np.int32(4), + prik_x, + np.int32(1), + beta, + prik_y, + np.int32(1), + ) + f2py_blas.cgbmv( + b"N", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + f2py_a, + f2py_x, + np.int32(1), + beta, + f2py_y, + np.int32(1), + lda=np.int32(4), + ) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zgbmv(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + original_a = np.asfortranarray( + [[91.0j, -1.0 + 2.0j], [2.0 + 1.0j, 3.0 - 1.0j], [4.0 + 0.5j, 92.0j], [93.0j, 94.0j]], dtype=np.complex128 + ) + x = np.array([2.0 + 1.0j, -3.0 + 0.5j], dtype=np.complex128) + original_y = np.array([4.0 - 1.0j, 5.0 + 2.0j], dtype=np.complex128) + logical_a = general_from_band(original_a, 2, 2, 1, 1) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.zgbmv( + "C", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + prik_a, + np.int32(4), + prik_x, + np.int32(1), + beta, + prik_y, + np.int32(1), + ) + f2py_blas.zgbmv( + b"C", + np.int32(2), + np.int32(2), + np.int32(1), + np.int32(1), + alpha, + f2py_a, + f2py_x, + np.int32(1), + beta, + f2py_y, + np.int32(1), + lda=np.int32(4), + ) + + expected_y = alpha * logical_a.conj().T @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_ssbmv(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + original_a = np.asfortranarray([[91.0, -1.0], [2.0, 3.0], [93.0, 94.0]], dtype=np.float32) + x = np.array([2.0, -3.0], dtype=np.float32) + original_y = np.array([4.0, 5.0], dtype=np.float32) + logical_a = symmetric_from_band(original_a, 2, 1, "U") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.ssbmv( + "U", np.int32(2), np.int32(1), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.ssbmv( + b"U", np.int32(2), np.int32(1), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dsbmv(prik_blas, f2py_blas): + alpha, beta = np.float64(-2.0), np.float64(1.0) + original_a = np.asfortranarray([[2.0, 3.0], [-1.0, 92.0], [93.0, 94.0]], dtype=np.float64) + x = np.array([2.0, -3.0], dtype=np.float64) + original_y = np.array([4.0, 5.0], dtype=np.float64) + logical_a = symmetric_from_band(original_a, 2, 1, "L") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.dsbmv( + "L", np.int32(2), np.int32(1), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.dsbmv( + b"L", np.int32(2), np.int32(1), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected_y = alpha * logical_a @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_chbmv(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + original_a = np.asfortranarray( + [[91.0j, -1.0 + 2.0j], [2.0 + 77.0j, 3.0 - 88.0j], [93.0j, 94.0j]], dtype=np.complex64 + ) + x = np.array([2.0 + 1.0j, -3.0 + 0.5j], dtype=np.complex64) + original_y = np.array([4.0 - 1.0j, 5.0 + 2.0j], dtype=np.complex64) + logical_a = hermitian_from_band(original_a, 2, 1, "U") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.chbmv( + "U", np.int32(2), np.int32(1), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.chbmv( + b"U", np.int32(2), np.int32(1), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zhbmv(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + original_a = np.asfortranarray( + [[2.0 + 77.0j, 3.0 - 88.0j], [-1.0 - 2.0j, 92.0j], [93.0j, 94.0j]], dtype=np.complex128 + ) + x = np.array([2.0 + 1.0j, -3.0 + 0.5j], dtype=np.complex128) + original_y = np.array([4.0 - 1.0j, 5.0 + 2.0j], dtype=np.complex128) + logical_a = hermitian_from_band(original_a, 2, 1, "L") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.zhbmv( + "L", np.int32(2), np.int32(1), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.zhbmv( + b"L", np.int32(2), np.int32(1), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected_y = alpha * logical_a @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_stbmv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[91.0, -1.0], [2.0, 3.0], [93.0, 94.0]], dtype=np.float32) + original_x = np.array([4.0, -2.0], dtype=np.float32) + logical_a = triangular_from_band(original_a, 2, 1, "U", unit_diagonal=False) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.stbmv("U", "N", "N", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.stbmv(b"U", b"N", b"N", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_dtbmv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[np.nan, np.nan], [-1.0, 92.0], [93.0, 94.0]], dtype=np.float64) + original_x = np.array([4.0, -2.0], dtype=np.float64) + logical_a = triangular_from_band(original_a, 2, 1, "L", unit_diagonal=True) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.dtbmv("L", "T", "U", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.dtbmv(b"L", b"T", b"U", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a.T @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ctbmv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[91.0j, -1.0 + 2.0j], [2.0 + 1.0j, 3.0 - 1.0j], [93.0j, 94.0j]], dtype=np.complex64) + original_x = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + logical_a = triangular_from_band(original_a, 2, 1, "U", unit_diagonal=False) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.ctbmv("U", "C", "N", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ctbmv(b"U", b"C", b"N", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a.conj().T @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ztbmv(prik_blas, f2py_blas): + nan = np.nan + 1.0j * np.nan + original_a = np.asfortranarray([[nan, nan], [-1.0 + 2.0j, 92.0j], [93.0j, 94.0j]], dtype=np.complex128) + original_x = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + logical_a = triangular_from_band(original_a, 2, 1, "L", unit_diagonal=True) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.ztbmv("L", "N", "U", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ztbmv(b"L", b"N", b"U", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_stbsv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[91.0, -1.0], [2.0, 3.0], [93.0, 94.0]], dtype=np.float32) + expected_solution = np.array([4.0, -2.0], dtype=np.float32) + logical_a = triangular_from_band(original_a, 2, 1, "U", unit_diagonal=False) + original_b = logical_a @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.stbsv("U", "N", "N", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.stbsv(b"U", b"N", b"N", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_dtbsv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[np.nan, np.nan], [-1.0, 92.0], [93.0, 94.0]], dtype=np.float64) + expected_solution = np.array([4.0, -2.0], dtype=np.float64) + logical_a = triangular_from_band(original_a, 2, 1, "L", unit_diagonal=True) + original_b = logical_a.T @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.dtbsv("L", "T", "U", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.dtbsv(b"L", b"T", b"U", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a.T @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a.T @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ctbsv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[91.0j, -1.0 + 2.0j], [2.0 + 1.0j, 3.0 - 1.0j], [93.0j, 94.0j]], dtype=np.complex64) + expected_solution = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + logical_a = triangular_from_band(original_a, 2, 1, "U", unit_diagonal=False) + original_b = logical_a.conj().T @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.ctbsv("U", "C", "N", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ctbsv(b"U", b"C", b"N", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a.conj().T @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a.conj().T @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ztbsv(prik_blas, f2py_blas): + original_a = np.asfortranarray( + [[2.0 + 1.0j, 3.0 - 1.0j], [-1.0 + 2.0j, 92.0j], [93.0j, 94.0j]], dtype=np.complex128 + ) + expected_solution = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + logical_a = triangular_from_band(original_a, 2, 1, "L", unit_diagonal=False) + original_b = logical_a @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.ztbsv("L", "N", "N", np.int32(2), np.int32(1), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ztbsv(b"L", b"N", b"N", np.int32(2), np.int32(1), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) diff --git a/examples/blas/tests/test_level2_general.py b/examples/blas/tests/test_level2_general.py new file mode 100644 index 000000000..e0a2dbfbe --- /dev/null +++ b/examples/blas/tests/test_level2_general.py @@ -0,0 +1,303 @@ +"""Readable independent and differential checks for general BLAS Level 2.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dgemv_no_transpose(prik_blas, f2py_blas): + alpha, beta = np.float64(2.0), np.float64(-1.0) + matrix = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [91.0, 92.0]], dtype=np.float64) + x = np.array([5.0, -2.0], dtype=np.float64) + original_y = np.array([7.0, 11.0], dtype=np.float64) + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_scalars = prik_blas.dgemv( + "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + # f2py places its inferred optional leading dimension after the native arrays. + f2py_result = f2py_blas.dgemv( + b"N", np.int32(2), np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + product = np.array([1.0 * 5.0 + 2.0 * (-2.0), 3.0 * 5.0 + 4.0 * (-2.0)]) + expected_y = alpha * product + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert prik_scalars == (2, 2, alpha, 3, 1, beta, 1) + assert f2py_result is None + assert_storage_unchanged(prik_a, matrix) + assert_storage_unchanged(f2py_a, matrix) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dgemv_transpose(prik_blas, f2py_blas): + alpha, beta = np.float64(1.0), np.float64(0.0) + matrix = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [93.0, 94.0]], dtype=np.float64) + x = np.array([5.0, -2.0], dtype=np.float64) + original_y = np.array([17.0, 19.0], dtype=np.float64) + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.dgemv( + "T", np.int32(2), np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.dgemv( + b"T", np.int32(2), np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected_y = np.array([1.0 * 5.0 + 3.0 * (-2.0), 2.0 * 5.0 + 4.0 * (-2.0)]) + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, matrix) + assert_storage_unchanged(f2py_a, matrix) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_sgemv(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(0.5) + matrix = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [91.0, 92.0]], dtype=np.float32) + x = np.array([2.0, -1.0], dtype=np.float32) + original_y = np.array([5.0, 6.0], dtype=np.float32) + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.sgemv( + "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.sgemv( + b"N", np.int32(2), np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected = alpha * np.array([1.0 * 2.0 + 2.0 * -1.0, 3.0 * 2.0 + 4.0 * -1.0]) + beta * original_y + assert_allclose_for_dtype(prik_y, expected, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, matrix) + assert_storage_unchanged(f2py_a, matrix) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_cgemv(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(-1.0j) + matrix = np.asfortranarray( + [[1.0 + 1.0j, 2.0 - 1.0j], [3.0 + 0.5j, 4.0 + 2.0j], [91.0j, 92.0j]], + dtype=np.complex64, + ) + x = np.array([2.0 - 1.0j, -1.0 + 0.5j], dtype=np.complex64) + original_y = np.array([5.0 + 1.0j, 6.0 - 2.0j], dtype=np.complex64) + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.cgemv( + "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.cgemv( + b"N", np.int32(2), np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected = ( + alpha * np.array([matrix[0, 0] * x[0] + matrix[0, 1] * x[1], matrix[1, 0] * x[0] + matrix[1, 1] * x[1]]) + + beta * original_y + ) + assert_allclose_for_dtype(prik_y, expected, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, matrix) + assert_storage_unchanged(f2py_a, matrix) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zgemv(prik_blas, f2py_blas): + alpha, beta = np.complex128(1.0 + 0.25j), np.complex128(0.0j) + matrix = np.asfortranarray( + [[1.0 + 1.0j, 2.0 - 1.0j], [3.0 + 0.5j, 4.0 + 2.0j], [91.0j, 92.0j]], + dtype=np.complex128, + ) + x = np.array([2.0 - 1.0j, -1.0 + 0.5j], dtype=np.complex128) + original_y = np.array([5.0 + 1.0j, 6.0 - 2.0j], dtype=np.complex128) + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.zgemv( + "C", np.int32(2), np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1) + ) + f2py_blas.zgemv( + b"C", np.int32(2), np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3) + ) + + expected = alpha * np.array( + [ + np.conj(matrix[0, 0]) * x[0] + np.conj(matrix[1, 0]) * x[1], + np.conj(matrix[0, 1]) * x[0] + np.conj(matrix[1, 1]) * x[1], + ] + ) + assert_allclose_for_dtype(prik_y, expected, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, matrix) + assert_storage_unchanged(f2py_a, matrix) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_sger(prik_blas, f2py_blas): + alpha = np.float32(2.0) + x = np.array([1.0, -2.0], dtype=np.float32) + y = np.array([3.0, 4.0], dtype=np.float32) + original = np.asfortranarray([[5.0, 6.0], [7.0, 8.0], [91.0, 92.0]], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original.copy(order="F"), original.copy(order="F") + + prik_blas.sger(np.int32(2), np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.sger(np.int32(2), np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected = original[:2, :] + alpha * x[:, None] * y[None, :] + assert_allclose_for_dtype(prik_a[:2, :], expected) + assert_allclose_for_dtype(f2py_a[:2, :], expected) + assert_allclose_for_dtype(prik_a[:2, :], f2py_a[:2, :]) + np.testing.assert_array_equal(prik_a[2, :], original[2, :], strict=True) + np.testing.assert_array_equal(f2py_a[2, :], original[2, :], strict=True) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_dger(prik_blas, f2py_blas): + alpha = np.float64(-0.5) + x = np.array([1.0, -2.0], dtype=np.float64) + y = np.array([3.0, 4.0], dtype=np.float64) + original = np.asfortranarray([[5.0, 6.0], [7.0, 8.0], [91.0, 92.0]], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original.copy(order="F"), original.copy(order="F") + + prik_blas.dger(np.int32(2), np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.dger(np.int32(2), np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected = original[:2, :] + alpha * x[:, None] * y[None, :] + assert_allclose_for_dtype(prik_a[:2, :], expected) + assert_allclose_for_dtype(f2py_a[:2, :], expected) + assert_allclose_for_dtype(prik_a[:2, :], f2py_a[:2, :]) + np.testing.assert_array_equal(prik_a[2, :], original[2, :], strict=True) + np.testing.assert_array_equal(f2py_a[2, :], original[2, :], strict=True) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_cgeru(prik_blas, f2py_blas): + alpha = np.complex64(1.0 - 0.5j) + x = np.array([1.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + y = np.array([3.0 - 1.0j, 4.0 + 2.0j], dtype=np.complex64) + original = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j], [91.0j, 92.0j]], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original.copy(order="F"), original.copy(order="F") + + prik_blas.cgeru(np.int32(2), np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.cgeru(np.int32(2), np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected = original[:2, :] + alpha * x[:, None] * y[None, :] + assert_allclose_for_dtype(prik_a[:2, :], expected) + assert_allclose_for_dtype(f2py_a[:2, :], expected) + assert_allclose_for_dtype(prik_a[:2, :], f2py_a[:2, :]) + np.testing.assert_array_equal(prik_a[2, :], original[2, :], strict=True) + np.testing.assert_array_equal(f2py_a[2, :], original[2, :], strict=True) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_zgeru(prik_blas, f2py_blas): + alpha = np.complex128(-0.25 + 0.75j) + x = np.array([1.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + y = np.array([3.0 - 1.0j, 4.0 + 2.0j], dtype=np.complex128) + original = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j], [91.0j, 92.0j]], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original.copy(order="F"), original.copy(order="F") + + prik_blas.zgeru(np.int32(2), np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.zgeru(np.int32(2), np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected = original[:2, :] + alpha * x[:, None] * y[None, :] + assert_allclose_for_dtype(prik_a[:2, :], expected) + assert_allclose_for_dtype(f2py_a[:2, :], expected) + assert_allclose_for_dtype(prik_a[:2, :], f2py_a[:2, :]) + np.testing.assert_array_equal(prik_a[2, :], original[2, :], strict=True) + np.testing.assert_array_equal(f2py_a[2, :], original[2, :], strict=True) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_cgerc(prik_blas, f2py_blas): + alpha = np.complex64(1.0 - 0.5j) + x = np.array([1.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + y = np.array([3.0 - 1.0j, 4.0 + 2.0j], dtype=np.complex64) + original = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j], [91.0j, 92.0j]], dtype=np.complex64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original.copy(order="F"), original.copy(order="F") + + prik_blas.cgerc(np.int32(2), np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.cgerc(np.int32(2), np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected = original[:2, :] + alpha * x[:, None] * np.conj(y)[None, :] + assert_allclose_for_dtype(prik_a[:2, :], expected) + assert_allclose_for_dtype(f2py_a[:2, :], expected) + assert_allclose_for_dtype(prik_a[:2, :], f2py_a[:2, :]) + np.testing.assert_array_equal(prik_a[2, :], original[2, :], strict=True) + np.testing.assert_array_equal(f2py_a[2, :], original[2, :], strict=True) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_zgerc(prik_blas, f2py_blas): + alpha = np.complex128(-0.25 + 0.75j) + x = np.array([1.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + y = np.array([3.0 - 1.0j, 4.0 + 2.0j], dtype=np.complex128) + original = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j], [91.0j, 92.0j]], dtype=np.complex128) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original.copy(order="F"), original.copy(order="F") + + prik_blas.zgerc(np.int32(2), np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.zgerc(np.int32(2), np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected = original[:2, :] + alpha * x[:, None] * np.conj(y)[None, :] + assert_allclose_for_dtype(prik_a[:2, :], expected) + assert_allclose_for_dtype(f2py_a[:2, :], expected) + assert_allclose_for_dtype(prik_a[:2, :], f2py_a[:2, :]) + np.testing.assert_array_equal(prik_a[2, :], original[2, :], strict=True) + np.testing.assert_array_equal(f2py_a[2, :], original[2, :], strict=True) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) diff --git a/examples/blas/tests/test_level2_hermitian.py b/examples/blas/tests/test_level2_hermitian.py new file mode 100644 index 000000000..b60f4c695 --- /dev/null +++ b/examples/blas/tests/test_level2_hermitian.py @@ -0,0 +1,175 @@ +"""Readable independent and differential checks for Hermitian BLAS Level 2.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged, hermitian_from_triangle + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_chemv(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + original_a = np.asfortranarray( + [[2.0 + 77.0j, 1.0 - 2.0j], [np.nan + 1.0j * np.nan, 3.0 - 88.0j], [91.0j, 92.0j]], dtype=np.complex64 + ) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex64) + original_y = np.array([4.0 - 2.0j, 5.0 + 3.0j], dtype=np.complex64) + logical_a = hermitian_from_triangle(original_a, 2, "U") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.chemv("U", np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.chemv(b"U", np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3)) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zhemv(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + original_a = np.asfortranarray( + [[2.0 + 77.0j, np.nan + 1.0j * np.nan], [1.0 + 2.0j, 3.0 - 88.0j], [91.0j, 92.0j]], dtype=np.complex128 + ) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex128) + original_y = np.array([4.0 - 2.0j, 5.0 + 3.0j], dtype=np.complex128) + logical_a = hermitian_from_triangle(original_a, 2, "L") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.zhemv("L", np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.zhemv(b"L", np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3)) + + expected_y = alpha * logical_a @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_cher(prik_blas, f2py_blas): + alpha = np.float32(0.75) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex64) + original_a = np.asfortranarray( + [[3.0 + 9.0j, 1.0 - 2.0j], [np.nan + 1.0j * np.nan, 4.0 - 8.0j], [91.0j, 92.0j]], dtype=np.complex64 + ) + prik_x, f2py_x = x.copy(), x.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.cher("U", np.int32(2), alpha, prik_x, np.int32(1), prik_a, np.int32(3)) + f2py_blas.cher(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_a, lda=np.int32(3)) + + expected_a = hermitian_from_triangle(original_a, 2, "U") + alpha * x[:, None] * np.conj(x[None, :]) + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][upper], expected_a[upper]) + assert_allclose_for_dtype(f2py_a[:2, :2][upper], expected_a[upper]) + assert_allclose_for_dtype(prik_a[:2, :2][upper], f2py_a[:2, :2][upper]) + assert np.all(np.imag(np.diag(prik_a[:2, :2])) == 0.0) + assert np.all(np.imag(np.diag(f2py_a[:2, :2])) == 0.0) + np.testing.assert_array_equal(prik_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zher(prik_blas, f2py_blas): + alpha = np.float64(-0.25) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex128) + original_a = np.asfortranarray( + [[3.0 + 9.0j, np.nan + 1.0j * np.nan], [1.0 + 2.0j, 4.0 - 8.0j], [91.0j, 92.0j]], dtype=np.complex128 + ) + prik_x, f2py_x = x.copy(), x.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.zher("L", np.int32(2), alpha, prik_x, np.int32(1), prik_a, np.int32(3)) + f2py_blas.zher(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_a, lda=np.int32(3)) + + expected_a = hermitian_from_triangle(original_a, 2, "L") + alpha * x[:, None] * np.conj(x[None, :]) + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][lower], expected_a[lower]) + assert_allclose_for_dtype(f2py_a[:2, :2][lower], expected_a[lower]) + assert_allclose_for_dtype(prik_a[:2, :2][lower], f2py_a[:2, :2][lower]) + assert np.all(np.imag(np.diag(prik_a[:2, :2])) == 0.0) + assert np.all(np.imag(np.diag(f2py_a[:2, :2])) == 0.0) + np.testing.assert_array_equal(prik_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_cher2(prik_blas, f2py_blas): + alpha = np.complex64(0.5 - 0.25j) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex64) + y = np.array([-3.0 + 0.5j, 4.0 - 2.0j], dtype=np.complex64) + original_a = np.asfortranarray( + [[3.0 + 9.0j, 1.0 - 2.0j], [np.nan + 1.0j * np.nan, 4.0 - 8.0j], [91.0j, 92.0j]], dtype=np.complex64 + ) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.cher2("U", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.cher2(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + logical_a = hermitian_from_triangle(original_a, 2, "U") + expected_a = ( + logical_a + alpha * x[:, None] * np.conj(y[None, :]) + np.conj(alpha) * y[:, None] * np.conj(x[None, :]) + ) + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][upper], expected_a[upper], operation_size=2) + assert_allclose_for_dtype(f2py_a[:2, :2][upper], expected_a[upper], operation_size=2) + assert_allclose_for_dtype(prik_a[:2, :2][upper], f2py_a[:2, :2][upper], operation_size=2) + assert np.all(np.imag(np.diag(prik_a[:2, :2])) == 0.0) + assert np.all(np.imag(np.diag(f2py_a[:2, :2])) == 0.0) + np.testing.assert_array_equal(prik_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_zher2(prik_blas, f2py_blas): + alpha = np.complex128(-0.75 + 0.5j) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex128) + y = np.array([-3.0 + 0.5j, 4.0 - 2.0j], dtype=np.complex128) + original_a = np.asfortranarray( + [[3.0 + 9.0j, np.nan + 1.0j * np.nan], [1.0 + 2.0j, 4.0 - 8.0j], [91.0j, 92.0j]], dtype=np.complex128 + ) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.zher2("L", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.zher2(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + logical_a = hermitian_from_triangle(original_a, 2, "L") + expected_a = ( + logical_a + alpha * x[:, None] * np.conj(y[None, :]) + np.conj(alpha) * y[:, None] * np.conj(x[None, :]) + ) + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][lower], expected_a[lower], operation_size=2) + assert_allclose_for_dtype(f2py_a[:2, :2][lower], expected_a[lower], operation_size=2) + assert_allclose_for_dtype(prik_a[:2, :2][lower], f2py_a[:2, :2][lower], operation_size=2) + assert np.all(np.imag(np.diag(prik_a[:2, :2])) == 0.0) + assert np.all(np.imag(np.diag(f2py_a[:2, :2])) == 0.0) + np.testing.assert_array_equal(prik_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) diff --git a/examples/blas/tests/test_level2_packed.py b/examples/blas/tests/test_level2_packed.py new file mode 100644 index 000000000..ad4667d9a --- /dev/null +++ b/examples/blas/tests/test_level2_packed.py @@ -0,0 +1,451 @@ +"""Readable independent and differential checks for packed BLAS Level 2.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import ( + assert_allclose_for_dtype, + assert_storage_unchanged, + hermitian_from_packed, + packed_from_triangle, + symmetric_from_packed, + triangular_from_packed, +) + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_sspmv(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + ap = packed_from_triangle(np.array([[2.0, -1.0], [91.0, 3.0]], dtype=np.float32), "U") + x = np.array([2.0, -3.0], dtype=np.float32) + original_y = np.array([4.0, 5.0], dtype=np.float32) + logical_a = symmetric_from_packed(ap, 2, "U") + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.sspmv("U", np.int32(2), alpha, prik_ap, prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.sspmv(b"U", np.int32(2), alpha, f2py_ap, f2py_x, np.int32(1), beta, f2py_y, np.int32(1)) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dspmv(prik_blas, f2py_blas): + alpha, beta = np.float64(-2.0), np.float64(1.0) + ap = packed_from_triangle(np.array([[2.0, 91.0], [-1.0, 3.0]], dtype=np.float64), "L") + x = np.array([2.0, -3.0], dtype=np.float64) + original_y = np.array([4.0, 5.0], dtype=np.float64) + logical_a = symmetric_from_packed(ap, 2, "L") + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.dspmv("L", np.int32(2), alpha, prik_ap, prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.dspmv(b"L", np.int32(2), alpha, f2py_ap, f2py_x, np.int32(1), beta, f2py_y, np.int32(1)) + + expected_y = alpha * logical_a @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_sspr(prik_blas, f2py_blas): + alpha = np.float32(0.75) + original_ap = packed_from_triangle(np.array([[3.0, 1.0], [91.0, 4.0]], dtype=np.float32), "U") + x = np.array([2.0, -1.0], dtype=np.float32) + logical_a = symmetric_from_packed(original_ap, 2, "U") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + + prik_blas.sspr("U", np.int32(2), alpha, prik_x, np.int32(1), prik_ap) + f2py_blas.sspr(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_ap) + + expected_ap = packed_from_triangle(logical_a + alpha * x[:, None] * x[None, :], "U") + assert_allclose_for_dtype(prik_ap, expected_ap) + assert_allclose_for_dtype(f2py_ap, expected_ap) + assert_allclose_for_dtype(prik_ap, f2py_ap) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dspr(prik_blas, f2py_blas): + alpha = np.float64(-0.5) + original_ap = packed_from_triangle(np.array([[3.0, 91.0], [1.0, 4.0]], dtype=np.float64), "L") + x = np.array([2.0, -1.0], dtype=np.float64) + logical_a = symmetric_from_packed(original_ap, 2, "L") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + + prik_blas.dspr("L", np.int32(2), alpha, prik_x, np.int32(1), prik_ap) + f2py_blas.dspr(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_ap) + + expected_ap = packed_from_triangle(logical_a + alpha * x[:, None] * x[None, :], "L") + assert_allclose_for_dtype(prik_ap, expected_ap) + assert_allclose_for_dtype(f2py_ap, expected_ap) + assert_allclose_for_dtype(prik_ap, f2py_ap) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_sspr2(prik_blas, f2py_blas): + alpha = np.float32(0.25) + original_ap = packed_from_triangle(np.array([[3.0, 1.0], [91.0, 4.0]], dtype=np.float32), "U") + x = np.array([2.0, -1.0], dtype=np.float32) + y = np.array([-3.0, 4.0], dtype=np.float32) + logical_a = symmetric_from_packed(original_ap, 2, "U") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.sspr2("U", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_ap) + f2py_blas.sspr2(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_ap) + + expected = logical_a + alpha * (x[:, None] * y[None, :] + y[:, None] * x[None, :]) + expected_ap = packed_from_triangle(expected, "U") + assert_allclose_for_dtype(prik_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(f2py_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(prik_ap, f2py_ap, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_dspr2(prik_blas, f2py_blas): + alpha = np.float64(-0.75) + original_ap = packed_from_triangle(np.array([[3.0, 91.0], [1.0, 4.0]], dtype=np.float64), "L") + x = np.array([2.0, -1.0], dtype=np.float64) + y = np.array([-3.0, 4.0], dtype=np.float64) + logical_a = symmetric_from_packed(original_ap, 2, "L") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.dspr2("L", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_ap) + f2py_blas.dspr2(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_ap) + + expected = logical_a + alpha * (x[:, None] * y[None, :] + y[:, None] * x[None, :]) + expected_ap = packed_from_triangle(expected, "L") + assert_allclose_for_dtype(prik_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(f2py_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(prik_ap, f2py_ap, operation_size=2) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_chpmv(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + ap = packed_from_triangle(np.array([[2.0 + 77.0j, 1.0 - 2.0j], [91.0j, 3.0 - 88.0j]], dtype=np.complex64), "U") + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex64) + original_y = np.array([4.0 - 2.0j, 5.0 + 3.0j], dtype=np.complex64) + logical_a = hermitian_from_packed(ap, 2, "U") + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.chpmv("U", np.int32(2), alpha, prik_ap, prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.chpmv(b"U", np.int32(2), alpha, f2py_ap, f2py_x, np.int32(1), beta, f2py_y, np.int32(1)) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zhpmv(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + ap = packed_from_triangle(np.array([[2.0 + 77.0j, 91.0j], [1.0 + 2.0j, 3.0 - 88.0j]], dtype=np.complex128), "L") + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex128) + original_y = np.array([4.0 - 2.0j, 5.0 + 3.0j], dtype=np.complex128) + logical_a = hermitian_from_packed(ap, 2, "L") + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.zhpmv("L", np.int32(2), alpha, prik_ap, prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.zhpmv(b"L", np.int32(2), alpha, f2py_ap, f2py_x, np.int32(1), beta, f2py_y, np.int32(1)) + + expected_y = alpha * logical_a @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_chpr(prik_blas, f2py_blas): + alpha = np.float32(0.75) + original_ap = packed_from_triangle( + np.array([[3.0 + 9.0j, 1.0 - 2.0j], [91.0j, 4.0 - 8.0j]], dtype=np.complex64), "U" + ) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex64) + logical_a = hermitian_from_packed(original_ap, 2, "U") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + + prik_blas.chpr("U", np.int32(2), alpha, prik_x, np.int32(1), prik_ap) + f2py_blas.chpr(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_ap) + + expected_ap = packed_from_triangle(logical_a + alpha * x[:, None] * np.conj(x[None, :]), "U") + assert_allclose_for_dtype(prik_ap, expected_ap) + assert_allclose_for_dtype(f2py_ap, expected_ap) + assert_allclose_for_dtype(prik_ap, f2py_ap) + assert np.all(np.imag(prik_ap[[0, 2]]) == 0.0) + assert np.all(np.imag(f2py_ap[[0, 2]]) == 0.0) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_zhpr(prik_blas, f2py_blas): + alpha = np.float64(-0.25) + original_ap = packed_from_triangle( + np.array([[3.0 + 9.0j, 91.0j], [1.0 + 2.0j, 4.0 - 8.0j]], dtype=np.complex128), "L" + ) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex128) + logical_a = hermitian_from_packed(original_ap, 2, "L") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + + prik_blas.zhpr("L", np.int32(2), alpha, prik_x, np.int32(1), prik_ap) + f2py_blas.zhpr(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_ap) + + expected_ap = packed_from_triangle(logical_a + alpha * x[:, None] * np.conj(x[None, :]), "L") + assert_allclose_for_dtype(prik_ap, expected_ap) + assert_allclose_for_dtype(f2py_ap, expected_ap) + assert_allclose_for_dtype(prik_ap, f2py_ap) + assert np.all(np.imag(prik_ap[[0, 2]]) == 0.0) + assert np.all(np.imag(f2py_ap[[0, 2]]) == 0.0) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_chpr2(prik_blas, f2py_blas): + alpha = np.complex64(0.5 - 0.25j) + original_ap = packed_from_triangle( + np.array([[3.0 + 9.0j, 1.0 - 2.0j], [91.0j, 4.0 - 8.0j]], dtype=np.complex64), "U" + ) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex64) + y = np.array([-3.0 + 0.5j, 4.0 - 2.0j], dtype=np.complex64) + logical_a = hermitian_from_packed(original_ap, 2, "U") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.chpr2("U", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_ap) + f2py_blas.chpr2(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_ap) + + expected = logical_a + alpha * x[:, None] * np.conj(y[None, :]) + np.conj(alpha) * y[:, None] * np.conj(x[None, :]) + expected_ap = packed_from_triangle(expected, "U") + assert_allclose_for_dtype(prik_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(f2py_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(prik_ap, f2py_ap, operation_size=2) + assert np.all(np.imag(prik_ap[[0, 2]]) == 0.0) + assert np.all(np.imag(f2py_ap[[0, 2]]) == 0.0) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_zhpr2(prik_blas, f2py_blas): + alpha = np.complex128(-0.75 + 0.5j) + original_ap = packed_from_triangle( + np.array([[3.0 + 9.0j, 91.0j], [1.0 + 2.0j, 4.0 - 8.0j]], dtype=np.complex128), "L" + ) + x = np.array([2.0 + 1.0j, -1.0 + 0.5j], dtype=np.complex128) + y = np.array([-3.0 + 0.5j, 4.0 - 2.0j], dtype=np.complex128) + logical_a = hermitian_from_packed(original_ap, 2, "L") + prik_ap, f2py_ap = original_ap.copy(), original_ap.copy() + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + + prik_blas.zhpr2("L", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_ap) + f2py_blas.zhpr2(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_ap) + + expected = logical_a + alpha * x[:, None] * np.conj(y[None, :]) + np.conj(alpha) * y[:, None] * np.conj(x[None, :]) + expected_ap = packed_from_triangle(expected, "L") + assert_allclose_for_dtype(prik_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(f2py_ap, expected_ap, operation_size=2) + assert_allclose_for_dtype(prik_ap, f2py_ap, operation_size=2) + assert np.all(np.imag(prik_ap[[0, 2]]) == 0.0) + assert np.all(np.imag(f2py_ap[[0, 2]]) == 0.0) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_stpmv(prik_blas, f2py_blas): + ap = packed_from_triangle(np.array([[2.0, -1.0], [91.0, 3.0]], dtype=np.float32), "U") + original_x = np.array([4.0, -2.0], dtype=np.float32) + logical_a = triangular_from_packed(ap, 2, "U", unit_diagonal=False) + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.stpmv("U", "N", "N", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.stpmv(b"U", b"N", b"N", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + expected_x = logical_a @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + + +def test_dtpmv(prik_blas, f2py_blas): + ap = packed_from_triangle(np.array([[np.nan, 91.0], [-1.0, np.nan]], dtype=np.float64), "L") + original_x = np.array([4.0, -2.0], dtype=np.float64) + logical_a = triangular_from_packed(ap, 2, "L", unit_diagonal=True) + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.dtpmv("L", "T", "U", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.dtpmv(b"L", b"T", b"U", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + expected_x = logical_a.T @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + + +def test_ctpmv(prik_blas, f2py_blas): + ap = packed_from_triangle(np.array([[2.0 + 1.0j, -1.0 + 2.0j], [91.0j, 3.0 - 1.0j]], dtype=np.complex64), "U") + original_x = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + logical_a = triangular_from_packed(ap, 2, "U", unit_diagonal=False) + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.ctpmv("U", "C", "N", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.ctpmv(b"U", b"C", b"N", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + expected_x = logical_a.conj().T @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + + +def test_ztpmv(prik_blas, f2py_blas): + nan = np.nan + 1.0j * np.nan + ap = packed_from_triangle(np.array([[nan, 91.0j], [-1.0 + 2.0j, nan]], dtype=np.complex128), "L") + original_x = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + logical_a = triangular_from_packed(ap, 2, "L", unit_diagonal=True) + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.ztpmv("L", "N", "U", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.ztpmv(b"L", b"N", b"U", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + expected_x = logical_a @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + + +def test_stpsv(prik_blas, f2py_blas): + ap = packed_from_triangle(np.array([[2.0, -1.0], [91.0, 3.0]], dtype=np.float32), "U") + expected_solution = np.array([4.0, -2.0], dtype=np.float32) + logical_a = triangular_from_packed(ap, 2, "U", unit_diagonal=False) + original_b = logical_a @ expected_solution + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.stpsv("U", "N", "N", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.stpsv(b"U", b"N", b"N", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + assert_allclose_for_dtype(logical_a @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + + +def test_dtpsv(prik_blas, f2py_blas): + ap = packed_from_triangle(np.array([[np.nan, 91.0], [-1.0, np.nan]], dtype=np.float64), "L") + expected_solution = np.array([4.0, -2.0], dtype=np.float64) + logical_a = triangular_from_packed(ap, 2, "L", unit_diagonal=True) + original_b = logical_a.T @ expected_solution + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.dtpsv("L", "T", "U", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.dtpsv(b"L", b"T", b"U", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + assert_allclose_for_dtype(logical_a.T @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a.T @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + + +def test_ctpsv(prik_blas, f2py_blas): + ap = packed_from_triangle(np.array([[2.0 + 1.0j, -1.0 + 2.0j], [91.0j, 3.0 - 1.0j]], dtype=np.complex64), "U") + expected_solution = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + logical_a = triangular_from_packed(ap, 2, "U", unit_diagonal=False) + original_b = logical_a.conj().T @ expected_solution + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.ctpsv("U", "C", "N", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.ctpsv(b"U", b"C", b"N", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + assert_allclose_for_dtype(logical_a.conj().T @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a.conj().T @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) + + +def test_ztpsv(prik_blas, f2py_blas): + ap = packed_from_triangle(np.array([[2.0 + 1.0j, 91.0j], [-1.0 + 2.0j, 3.0 - 1.0j]], dtype=np.complex128), "L") + expected_solution = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + logical_a = triangular_from_packed(ap, 2, "L", unit_diagonal=False) + original_b = logical_a @ expected_solution + prik_ap, f2py_ap = ap.copy(), ap.copy() + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.ztpsv("L", "N", "N", np.int32(2), prik_ap, prik_x, np.int32(1)) + f2py_blas.ztpsv(b"L", b"N", b"N", np.int32(2), f2py_ap, f2py_x, np.int32(1)) + + assert_allclose_for_dtype(logical_a @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_ap, ap) + assert_storage_unchanged(f2py_ap, ap) diff --git a/examples/blas/tests/test_level2_symmetric.py b/examples/blas/tests/test_level2_symmetric.py new file mode 100644 index 000000000..6938914d2 --- /dev/null +++ b/examples/blas/tests/test_level2_symmetric.py @@ -0,0 +1,153 @@ +"""Readable independent and differential checks for symmetric BLAS Level 2.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged, symmetric_from_triangle + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_ssymv(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + original_a = np.asfortranarray([[2.0, -1.0], [np.nan, 3.0], [91.0, 92.0]], dtype=np.float32) + x = np.array([2.0, -3.0], dtype=np.float32) + original_y = np.array([4.0, 5.0], dtype=np.float32) + logical_a = symmetric_from_triangle(original_a, 2, "U") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.ssymv("U", np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.ssymv(b"U", np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3)) + + expected_y = alpha * logical_a @ x + beta * original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dsymv(prik_blas, f2py_blas): + alpha, beta = np.float64(-2.0), np.float64(1.0) + original_a = np.asfortranarray([[2.0, np.nan], [-1.0, 3.0], [91.0, 92.0]], dtype=np.float64) + x = np.array([2.0, -3.0], dtype=np.float64) + original_y = np.array([4.0, 5.0], dtype=np.float64) + logical_a = symmetric_from_triangle(original_a, 2, "L") + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = original_y.copy(), original_y.copy() + + prik_blas.dsymv("L", np.int32(2), alpha, prik_a, np.int32(3), prik_x, np.int32(1), beta, prik_y, np.int32(1)) + f2py_blas.dsymv(b"L", np.int32(2), alpha, f2py_a, f2py_x, np.int32(1), beta, f2py_y, np.int32(1), lda=np.int32(3)) + + expected_y = alpha * logical_a @ x + original_y + assert_allclose_for_dtype(prik_y, expected_y, operation_size=2) + assert_allclose_for_dtype(f2py_y, expected_y, operation_size=2) + assert_allclose_for_dtype(prik_y, f2py_y, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_ssyr(prik_blas, f2py_blas): + alpha = np.float32(0.75) + x = np.array([2.0, -1.0], dtype=np.float32) + original_a = np.asfortranarray([[3.0, 1.0], [np.nan, 4.0], [91.0, 92.0]], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.ssyr("U", np.int32(2), alpha, prik_x, np.int32(1), prik_a, np.int32(3)) + f2py_blas.ssyr(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_a, lda=np.int32(3)) + + expected_a = original_a[:2, :2] + alpha * x[:, None] * x[None, :] + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][upper], expected_a[upper]) + assert_allclose_for_dtype(f2py_a[:2, :2][upper], expected_a[upper]) + assert_allclose_for_dtype(prik_a[:2, :2][upper], f2py_a[:2, :2][upper]) + np.testing.assert_array_equal(prik_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(prik_a[2, :], original_a[2, :]) + np.testing.assert_array_equal(f2py_a[2, :], original_a[2, :]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_dsyr(prik_blas, f2py_blas): + alpha = np.float64(-0.5) + x = np.array([2.0, -1.0], dtype=np.float64) + original_a = np.asfortranarray([[3.0, np.nan], [1.0, 4.0], [91.0, 92.0]], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.dsyr("L", np.int32(2), alpha, prik_x, np.int32(1), prik_a, np.int32(3)) + f2py_blas.dsyr(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_a, lda=np.int32(3)) + + expected_a = original_a[:2, :2] + alpha * x[:, None] * x[None, :] + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][lower], expected_a[lower]) + assert_allclose_for_dtype(f2py_a[:2, :2][lower], expected_a[lower]) + assert_allclose_for_dtype(prik_a[:2, :2][lower], f2py_a[:2, :2][lower]) + np.testing.assert_array_equal(prik_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(prik_a[2, :], original_a[2, :]) + np.testing.assert_array_equal(f2py_a[2, :], original_a[2, :]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + + +def test_ssyr2(prik_blas, f2py_blas): + alpha = np.float32(0.25) + x = np.array([2.0, -1.0], dtype=np.float32) + y = np.array([-3.0, 4.0], dtype=np.float32) + original_a = np.asfortranarray([[3.0, 1.0], [np.nan, 4.0], [91.0, 92.0]], dtype=np.float32) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.ssyr2("U", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.ssyr2(b"U", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected_a = original_a[:2, :2] + alpha * (x[:, None] * y[None, :] + y[:, None] * x[None, :]) + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][upper], expected_a[upper]) + assert_allclose_for_dtype(f2py_a[:2, :2][upper], expected_a[upper]) + assert_allclose_for_dtype(prik_a[:2, :2][upper], f2py_a[:2, :2][upper]) + np.testing.assert_array_equal(prik_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_a[np.tril_indices(2, -1)], original_a[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) + + +def test_dsyr2(prik_blas, f2py_blas): + alpha = np.float64(-0.75) + x = np.array([2.0, -1.0], dtype=np.float64) + y = np.array([-3.0, 4.0], dtype=np.float64) + original_a = np.asfortranarray([[3.0, np.nan], [1.0, 4.0], [91.0, 92.0]], dtype=np.float64) + prik_x, f2py_x = x.copy(), x.copy() + prik_y, f2py_y = y.copy(), y.copy() + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + + prik_blas.dsyr2("L", np.int32(2), alpha, prik_x, np.int32(1), prik_y, np.int32(1), prik_a, np.int32(3)) + f2py_blas.dsyr2(b"L", np.int32(2), alpha, f2py_x, np.int32(1), f2py_y, np.int32(1), f2py_a, lda=np.int32(3)) + + expected_a = original_a[:2, :2] + alpha * (x[:, None] * y[None, :] + y[:, None] * x[None, :]) + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_a[:2, :2][lower], expected_a[lower]) + assert_allclose_for_dtype(f2py_a[:2, :2][lower], expected_a[lower]) + assert_allclose_for_dtype(prik_a[:2, :2][lower], f2py_a[:2, :2][lower]) + np.testing.assert_array_equal(prik_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_a[np.triu_indices(2, 1)], original_a[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_x, x) + assert_storage_unchanged(f2py_x, x) + assert_storage_unchanged(prik_y, y) + assert_storage_unchanged(f2py_y, y) diff --git a/examples/blas/tests/test_level2_triangular.py b/examples/blas/tests/test_level2_triangular.py new file mode 100644 index 000000000..e9bcc2860 --- /dev/null +++ b/examples/blas/tests/test_level2_triangular.py @@ -0,0 +1,173 @@ +"""Readable independent and differential checks for triangular BLAS Level 2.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged, triangular_from_triangle + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_strmv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[2.0, -1.0], [np.nan, 3.0], [91.0, 92.0]], dtype=np.float32) + original_x = np.array([4.0, -2.0], dtype=np.float32) + logical_a = triangular_from_triangle(original_a, 2, "U", unit_diagonal=False) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.strmv("U", "N", "N", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.strmv(b"U", b"N", b"N", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_dtrmv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[np.nan, np.nan], [-1.0, np.nan], [91.0, 92.0]], dtype=np.float64) + original_x = np.array([4.0, -2.0], dtype=np.float64) + logical_a = triangular_from_triangle(original_a, 2, "L", unit_diagonal=True) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.dtrmv("L", "T", "U", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.dtrmv(b"L", b"T", b"U", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a.T @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ctrmv(prik_blas, f2py_blas): + original_a = np.asfortranarray( + [[2.0 + 1.0j, -1.0 + 2.0j], [np.nan + 1.0j * np.nan, 3.0 - 1.0j], [91.0j, 92.0j]], dtype=np.complex64 + ) + original_x = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + logical_a = triangular_from_triangle(original_a, 2, "U", unit_diagonal=False) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.ctrmv("U", "C", "N", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ctrmv(b"U", b"C", b"N", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a.conj().T @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ztrmv(prik_blas, f2py_blas): + original_a = np.asfortranarray( + [[np.nan + 1.0j * np.nan, np.nan + 1.0j * np.nan], [-1.0 + 2.0j, np.nan + 1.0j * np.nan], [91.0j, 92.0j]], + dtype=np.complex128, + ) + original_x = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + logical_a = triangular_from_triangle(original_a, 2, "L", unit_diagonal=True) + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_x.copy(), original_x.copy() + + prik_blas.ztrmv("L", "N", "U", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ztrmv(b"L", b"N", b"U", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + expected_x = logical_a @ original_x + assert_allclose_for_dtype(prik_x, expected_x, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_x, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_strsv(prik_blas, f2py_blas): + original_a = np.asfortranarray([[2.0, -1.0], [np.nan, 3.0], [91.0, 92.0]], dtype=np.float32) + expected_solution = np.array([4.0, -2.0], dtype=np.float32) + logical_a = triangular_from_triangle(original_a, 2, "U", unit_diagonal=False) + original_b = logical_a @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.strsv("U", "N", "N", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.strsv(b"U", b"N", b"N", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_dtrsv_upper_nonunit(prik_blas, f2py_blas): + original_a = np.asfortranarray([[2.0, -1.0], [np.nan, 3.0], [91.0, 92.0]], dtype=np.float64) + expected_solution = np.array([4.0, -2.0], dtype=np.float64) + logical_a = triangular_from_triangle(original_a, 2, "U", unit_diagonal=False) + original_b = logical_a.T @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.dtrsv("U", "T", "N", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.dtrsv(b"U", b"T", b"N", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a.T @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a.T @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ctrsv(prik_blas, f2py_blas): + original_a = np.asfortranarray( + [[np.nan + 1.0j * np.nan, np.nan + 1.0j * np.nan], [-1.0 + 2.0j, np.nan + 1.0j * np.nan], [91.0j, 92.0j]], + dtype=np.complex64, + ) + expected_solution = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex64) + logical_a = triangular_from_triangle(original_a, 2, "L", unit_diagonal=True) + original_b = logical_a.conj().T @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.ctrsv("L", "C", "U", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ctrsv(b"L", b"C", b"U", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a.conj().T @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a.conj().T @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) + + +def test_ztrsv(prik_blas, f2py_blas): + original_a = np.asfortranarray( + [[2.0 + 1.0j, np.nan + 1.0j * np.nan], [-1.0 + 2.0j, 3.0 - 1.0j], [91.0j, 92.0j]], dtype=np.complex128 + ) + expected_solution = np.array([4.0 + 1.0j, -2.0 + 0.5j], dtype=np.complex128) + logical_a = triangular_from_triangle(original_a, 2, "L", unit_diagonal=False) + original_b = logical_a @ expected_solution + prik_a, f2py_a = original_a.copy(order="F"), original_a.copy(order="F") + prik_x, f2py_x = original_b.copy(), original_b.copy() + + prik_blas.ztrsv("L", "N", "N", np.int32(2), prik_a, np.int32(3), prik_x, np.int32(1)) + f2py_blas.ztrsv(b"L", b"N", b"N", np.int32(2), f2py_a, f2py_x, np.int32(1), lda=np.int32(3)) + + assert_allclose_for_dtype(logical_a @ prik_x, original_b, operation_size=2) + assert_allclose_for_dtype(logical_a @ f2py_x, original_b, operation_size=2) + assert_allclose_for_dtype(prik_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(f2py_x, expected_solution, operation_size=2) + assert_allclose_for_dtype(prik_x, f2py_x, operation_size=2) + assert_storage_unchanged(prik_a, original_a) + assert_storage_unchanged(f2py_a, original_a) diff --git a/examples/blas/tests/test_level3_general.py b/examples/blas/tests/test_level3_general.py new file mode 100644 index 000000000..7a85ffce1 --- /dev/null +++ b/examples/blas/tests/test_level3_general.py @@ -0,0 +1,432 @@ +"""Readable independent and differential checks for general BLAS Level 3.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dgemm(prik_blas, f2py_blas): + alpha, beta = np.float64(2.0), np.float64(-0.5) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [91.0, 92.0]], dtype=np.float64) + b = np.asfortranarray([[5.0, 6.0], [7.0, 8.0], [93.0, 94.0]], dtype=np.float64) + original_c = np.asfortranarray([[9.0, 10.0], [11.0, 12.0], [95.0, 96.0]], dtype=np.float64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_scalars = prik_blas.dgemm( + "N", + "N", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(3), + prik_b, + np.int32(3), + beta, + prik_c, + np.int32(3), + ) + # f2py moves its inferred optional leading dimensions to keyword arguments. + f2py_result = f2py_blas.dgemm( + b"N", + b"N", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(3), + ldb=np.int32(3), + ldc=np.int32(3), + ) + + product = np.array( + [[1.0 * 5.0 + 2.0 * 7.0, 1.0 * 6.0 + 2.0 * 8.0], [3.0 * 5.0 + 4.0 * 7.0, 3.0 * 6.0 + 4.0 * 8.0]], + dtype=np.float64, + ) + expected_active = alpha * product + beta * original_c[:2, :] + assert_allclose_for_dtype(prik_c[:2, :], expected_active, operation_size=2) + assert_allclose_for_dtype(f2py_c[:2, :], expected_active, operation_size=2) + assert_allclose_for_dtype(prik_c[:2, :], f2py_c[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_c[2, :], original_c[2, :], strict=True) + np.testing.assert_array_equal(f2py_c[2, :], original_c[2, :], strict=True) + assert prik_scalars == (2, 2, 2, alpha, 3, 3, beta, 3) + assert f2py_result is None + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_sgemm(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(0.0) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) + b = np.asfortranarray([[5.0, 6.0], [7.0, 8.0]], dtype=np.float32) + original_c = np.asfortranarray([[9.0, 10.0], [11.0, 12.0]], dtype=np.float32) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.sgemm( + "N", + "N", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(2), + prik_b, + np.int32(2), + beta, + prik_c, + np.int32(2), + ) + f2py_blas.sgemm( + b"N", + b"N", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a @ b) + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_cgemm(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(1.0) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex64) + original_c = np.asfortranarray([[9.0j, 10.0], [11.0, 12.0j]], dtype=np.complex64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.cgemm( + "N", + "C", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(2), + prik_b, + np.int32(2), + beta, + prik_c, + np.int32(2), + ) + f2py_blas.cgemm( + b"N", + b"C", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a @ b.conj().T) + original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_zgemm(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(-1.0j) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex128) + original_c = np.asfortranarray([[9.0j, 10.0], [11.0, 12.0j]], dtype=np.complex128) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zgemm( + "T", + "N", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(2), + prik_b, + np.int32(2), + beta, + prik_c, + np.int32(2), + ) + f2py_blas.zgemm( + b"T", + b"N", + np.int32(2), + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a.T @ b) + beta * original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_sgemmtr(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) + b = np.asfortranarray([[5.0, 6.0], [7.0, 8.0]], dtype=np.float32) + original_c = np.asfortranarray([[9.0, 10.0], [np.nan, 12.0]], dtype=np.float32) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.sgemmtr( + "U", + "N", + "N", + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(2), + prik_b, + np.int32(2), + beta, + prik_c, + np.int32(2), + ) + f2py_blas.sgemmtr( + b"U", + b"N", + b"N", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a @ b) + beta * original_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=2) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_dgemmtr(prik_blas, f2py_blas): + alpha, beta = np.float64(-0.75), np.float64(1.0) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64) + b = np.asfortranarray([[5.0, 6.0], [7.0, 8.0]], dtype=np.float64) + original_c = np.asfortranarray([[9.0, np.nan], [11.0, 12.0]], dtype=np.float64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.dgemmtr( + "L", + "T", + "N", + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(2), + prik_b, + np.int32(2), + beta, + prik_c, + np.int32(2), + ) + f2py_blas.dgemmtr( + b"L", + b"T", + b"N", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a.T @ b) + original_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=2) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_cgemmtr(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex64) + original_c = np.asfortranarray([[9.0j, 10.0], [np.nan + 1.0j * np.nan, 12.0j]], dtype=np.complex64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.cgemmtr( + "U", + "N", + "C", + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(2), + prik_b, + np.int32(2), + beta, + prik_c, + np.int32(2), + ) + f2py_blas.cgemmtr( + b"U", + b"N", + b"C", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a @ b.conj().T) + beta * original_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=2) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_zgemmtr(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex128) + original_c = np.asfortranarray([[9.0j, np.nan + 1.0j * np.nan], [11.0, 12.0j]], dtype=np.complex128) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zgemmtr( + "L", + "C", + "N", + np.int32(2), + np.int32(2), + alpha, + prik_a, + np.int32(2), + prik_b, + np.int32(2), + beta, + prik_c, + np.int32(2), + ) + f2py_blas.zgemmtr( + b"L", + b"C", + b"N", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a.conj().T @ b) + original_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=2) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) diff --git a/examples/blas/tests/test_level3_hermitian.py b/examples/blas/tests/test_level3_hermitian.py new file mode 100644 index 000000000..895fbf87f --- /dev/null +++ b/examples/blas/tests/test_level3_hermitian.py @@ -0,0 +1,229 @@ +"""Readable independent and differential checks for Hermitian BLAS Level 3.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged, hermitian_from_triangle + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_chemm(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + a = np.asfortranarray([[2.0 + 77.0j, -1.0 + 2.0j], [np.nan + 1.0j * np.nan, 3.0 - 88.0j]], dtype=np.complex64) + b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + original_c = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j]], dtype=np.complex64) + logical_a = hermitian_from_triangle(a, 2, "U") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.chemm( + "L", "U", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.chemm( + b"L", + b"U", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * logical_a @ b + beta * original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_zhemm(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + a = np.asfortranarray([[2.0 + 77.0j, np.nan + 1.0j * np.nan], [-1.0 - 2.0j, 3.0 - 88.0j]], dtype=np.complex128) + b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + original_c = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j]], dtype=np.complex128) + logical_a = hermitian_from_triangle(a, 2, "L") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zhemm( + "R", "L", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.zhemm( + b"R", + b"L", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * b @ logical_a + original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_cherk(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + original_c = np.asfortranarray( + [[5.0 + 77.0j, 6.0 - 2.0j], [np.nan + 1.0j * np.nan, 8.0 - 88.0j]], dtype=np.complex64 + ) + logical_c = hermitian_from_triangle(original_c, 2, "U") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.cherk("U", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), beta, prik_c, np.int32(2)) + f2py_blas.cherk(b"U", b"N", np.int32(2), np.int32(2), alpha, f2py_a, beta, f2py_c, lda=np.int32(2), ldc=np.int32(2)) + + expected_c = alpha * (a @ a.conj().T) + beta * logical_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=2) + assert np.all(np.imag(np.diag(prik_c)) == 0.0) + assert np.all(np.imag(np.diag(f2py_c)) == 0.0) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_zherk(prik_blas, f2py_blas): + alpha, beta = np.float64(-0.75), np.float64(1.0) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + original_c = np.asfortranarray( + [[5.0 + 77.0j, np.nan + 1.0j * np.nan], [6.0 + 2.0j, 8.0 - 88.0j]], dtype=np.complex128 + ) + logical_c = hermitian_from_triangle(original_c, 2, "L") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zherk("L", "C", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), beta, prik_c, np.int32(2)) + f2py_blas.zherk(b"L", b"C", np.int32(2), np.int32(2), alpha, f2py_a, beta, f2py_c, lda=np.int32(2), ldc=np.int32(2)) + + expected_c = alpha * (a.conj().T @ a) + logical_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=2) + assert np.all(np.imag(np.diag(prik_c)) == 0.0) + assert np.all(np.imag(np.diag(f2py_c)) == 0.0) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_cher2k(prik_blas, f2py_blas): + alpha, beta = np.complex64(0.5 - 0.25j), np.float32(-0.5) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex64) + original_c = np.asfortranarray( + [[9.0 + 77.0j, 10.0 - 2.0j], [np.nan + 1.0j * np.nan, 12.0 - 88.0j]], dtype=np.complex64 + ) + logical_c = hermitian_from_triangle(original_c, 2, "U") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.cher2k( + "U", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.cher2k( + b"U", + b"N", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a @ b.conj().T) + np.conj(alpha) * (b @ a.conj().T) + beta * logical_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=4) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=4) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=4) + assert np.all(np.imag(np.diag(prik_c)) == 0.0) + assert np.all(np.imag(np.diag(f2py_c)) == 0.0) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_zher2k(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.75 + 0.5j), np.float64(1.0) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex128) + original_c = np.asfortranarray( + [[9.0 + 77.0j, np.nan + 1.0j * np.nan], [10.0 + 2.0j, 12.0 - 88.0j]], dtype=np.complex128 + ) + logical_c = hermitian_from_triangle(original_c, 2, "L") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zher2k( + "L", "C", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.zher2k( + b"L", + b"C", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a.conj().T @ b) + np.conj(alpha) * (b.conj().T @ a) + logical_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=4) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=4) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=4) + assert np.all(np.imag(np.diag(prik_c)) == 0.0) + assert np.all(np.imag(np.diag(f2py_c)) == 0.0) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) diff --git a/examples/blas/tests/test_level3_symmetric.py b/examples/blas/tests/test_level3_symmetric.py new file mode 100644 index 000000000..d80942dae --- /dev/null +++ b/examples/blas/tests/test_level3_symmetric.py @@ -0,0 +1,407 @@ +"""Readable independent and differential checks for symmetric BLAS Level 3.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged, symmetric_from_triangle + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_ssymm(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + a = np.asfortranarray([[2.0, -1.0], [np.nan, 3.0]], dtype=np.float32) + b = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) + original_c = np.asfortranarray([[5.0, 6.0], [7.0, 8.0]], dtype=np.float32) + logical_a = symmetric_from_triangle(a, 2, "U") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.ssymm( + "L", "U", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.ssymm( + b"L", + b"U", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * logical_a @ b + beta * original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_dsymm(prik_blas, f2py_blas): + alpha, beta = np.float64(-2.0), np.float64(1.0) + a = np.asfortranarray([[2.0, np.nan], [-1.0, 3.0]], dtype=np.float64) + b = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64) + original_c = np.asfortranarray([[5.0, 6.0], [7.0, 8.0]], dtype=np.float64) + logical_a = symmetric_from_triangle(a, 2, "L") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.dsymm( + "R", "L", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.dsymm( + b"R", + b"L", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * b @ logical_a + original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_csymm(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + a = np.asfortranarray([[2.0 + 1.0j, -1.0 + 2.0j], [np.nan + 1.0j * np.nan, 3.0 - 1.0j]], dtype=np.complex64) + b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + original_c = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j]], dtype=np.complex64) + logical_a = symmetric_from_triangle(a, 2, "U") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.csymm( + "L", "U", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.csymm( + b"L", + b"U", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * logical_a @ b + beta * original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_zsymm(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + a = np.asfortranarray([[2.0 + 1.0j, np.nan + 1.0j * np.nan], [-1.0 + 2.0j, 3.0 - 1.0j]], dtype=np.complex128) + b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + original_c = np.asfortranarray([[5.0j, 6.0], [7.0, 8.0j]], dtype=np.complex128) + logical_a = symmetric_from_triangle(a, 2, "L") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zsymm( + "R", "L", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.zsymm( + b"R", + b"L", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * b @ logical_a + original_c + assert_allclose_for_dtype(prik_c, expected_c, operation_size=2) + assert_allclose_for_dtype(f2py_c, expected_c, operation_size=2) + assert_allclose_for_dtype(prik_c, f2py_c, operation_size=2) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_ssyrk(prik_blas, f2py_blas): + alpha, beta = np.float32(1.5), np.float32(-0.5) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) + original_c = np.asfortranarray([[5.0, 6.0], [np.nan, 8.0]], dtype=np.float32) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.ssyrk("U", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), beta, prik_c, np.int32(2)) + f2py_blas.ssyrk(b"U", b"N", np.int32(2), np.int32(2), alpha, f2py_a, beta, f2py_c, lda=np.int32(2), ldc=np.int32(2)) + + expected_c = alpha * (a @ a.T) + beta * original_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=2) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_dsyrk(prik_blas, f2py_blas): + alpha, beta = np.float64(-0.75), np.float64(1.0) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64) + original_c = np.asfortranarray([[5.0, np.nan], [7.0, 8.0]], dtype=np.float64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.dsyrk("L", "T", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), beta, prik_c, np.int32(2)) + f2py_blas.dsyrk(b"L", b"T", np.int32(2), np.int32(2), alpha, f2py_a, beta, f2py_c, lda=np.int32(2), ldc=np.int32(2)) + + expected_c = alpha * (a.T @ a) + original_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=2) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_csyrk(prik_blas, f2py_blas): + alpha, beta = np.complex64(1.0 - 0.5j), np.complex64(0.25j) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + original_c = np.asfortranarray([[5.0j, 6.0], [np.nan + 1.0j * np.nan, 8.0j]], dtype=np.complex64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.csyrk("U", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), beta, prik_c, np.int32(2)) + f2py_blas.csyrk(b"U", b"N", np.int32(2), np.int32(2), alpha, f2py_a, beta, f2py_c, lda=np.int32(2), ldc=np.int32(2)) + + expected_c = alpha * (a @ a.T) + beta * original_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=2) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=2) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_zsyrk(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.5 + 0.25j), np.complex128(1.0) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + original_c = np.asfortranarray([[5.0j, np.nan + 1.0j * np.nan], [7.0, 8.0j]], dtype=np.complex128) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zsyrk("L", "T", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), beta, prik_c, np.int32(2)) + f2py_blas.zsyrk(b"L", b"T", np.int32(2), np.int32(2), alpha, f2py_a, beta, f2py_c, lda=np.int32(2), ldc=np.int32(2)) + + expected_c = alpha * (a.T @ a) + original_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=2) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=2) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_ssyr2k(prik_blas, f2py_blas): + alpha, beta = np.float32(0.75), np.float32(-0.5) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float32) + b = np.asfortranarray([[5.0, 6.0], [7.0, 8.0]], dtype=np.float32) + original_c = np.asfortranarray([[9.0, 10.0], [np.nan, 12.0]], dtype=np.float32) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.ssyr2k( + "U", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.ssyr2k( + b"U", + b"N", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a @ b.T + b @ a.T) + beta * original_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=4) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=4) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=4) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_dsyr2k(prik_blas, f2py_blas): + alpha, beta = np.float64(-0.25), np.float64(1.0) + a = np.asfortranarray([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64) + b = np.asfortranarray([[5.0, 6.0], [7.0, 8.0]], dtype=np.float64) + original_c = np.asfortranarray([[9.0, np.nan], [11.0, 12.0]], dtype=np.float64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.dsyr2k( + "L", "T", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.dsyr2k( + b"L", + b"T", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a.T @ b + b.T @ a) + original_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=4) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=4) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=4) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_csyr2k(prik_blas, f2py_blas): + alpha, beta = np.complex64(0.5 - 0.25j), np.complex64(0.25j) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex64) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex64) + original_c = np.asfortranarray([[9.0j, 10.0], [np.nan + 1.0j * np.nan, 12.0j]], dtype=np.complex64) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.csyr2k( + "U", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.csyr2k( + b"U", + b"N", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a @ b.T + b @ a.T) + beta * original_c + upper = np.triu_indices(2) + assert_allclose_for_dtype(prik_c[upper], expected_c[upper], operation_size=4) + assert_allclose_for_dtype(f2py_c[upper], expected_c[upper], operation_size=4) + assert_allclose_for_dtype(prik_c[upper], f2py_c[upper], operation_size=4) + np.testing.assert_array_equal(prik_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + np.testing.assert_array_equal(f2py_c[np.tril_indices(2, -1)], original_c[np.tril_indices(2, -1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) + + +def test_zsyr2k(prik_blas, f2py_blas): + alpha, beta = np.complex128(-0.75 + 0.5j), np.complex128(1.0) + a = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j]], dtype=np.complex128) + b = np.asfortranarray([[5.0 + 2.0j, 6.0], [7.0 - 1.0j, 8.0 + 1.0j]], dtype=np.complex128) + original_c = np.asfortranarray([[9.0j, np.nan + 1.0j * np.nan], [11.0, 12.0j]], dtype=np.complex128) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_c, f2py_c = original_c.copy(order="F"), original_c.copy(order="F") + + prik_blas.zsyr2k( + "L", "T", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(2), beta, prik_c, np.int32(2) + ) + f2py_blas.zsyr2k( + b"L", + b"T", + np.int32(2), + np.int32(2), + alpha, + f2py_a, + f2py_b, + beta, + f2py_c, + lda=np.int32(2), + ldb=np.int32(2), + ldc=np.int32(2), + ) + + expected_c = alpha * (a.T @ b + b.T @ a) + original_c + lower = np.tril_indices(2) + assert_allclose_for_dtype(prik_c[lower], expected_c[lower], operation_size=4) + assert_allclose_for_dtype(f2py_c[lower], expected_c[lower], operation_size=4) + assert_allclose_for_dtype(prik_c[lower], f2py_c[lower], operation_size=4) + np.testing.assert_array_equal(prik_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + np.testing.assert_array_equal(f2py_c[np.triu_indices(2, 1)], original_c[np.triu_indices(2, 1)]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + assert_storage_unchanged(prik_b, b) + assert_storage_unchanged(f2py_b, b) diff --git a/examples/blas/tests/test_level3_triangular.py b/examples/blas/tests/test_level3_triangular.py new file mode 100644 index 000000000..0437a3eec --- /dev/null +++ b/examples/blas/tests/test_level3_triangular.py @@ -0,0 +1,207 @@ +"""Readable independent and differential checks for triangular BLAS Level 3.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_for_dtype, assert_storage_unchanged, triangular_from_triangle + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_strmm(prik_blas, f2py_blas): + alpha = np.float32(1.5) + a = np.asfortranarray([[2.0, -1.0], [np.nan, 3.0]], dtype=np.float32) + original_b = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [91.0, 92.0]], dtype=np.float32) + logical_a = triangular_from_triangle(a, 2, "U", unit_diagonal=False) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.strmm("L", "U", "N", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.strmm( + b"L", b"U", b"N", b"N", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = alpha * logical_a @ original_b[:2, :] + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_dtrmm(prik_blas, f2py_blas): + alpha = np.float64(-0.5) + a = np.asfortranarray([[np.nan, np.nan], [-1.0, np.nan]], dtype=np.float64) + original_b = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [91.0, 92.0]], dtype=np.float64) + logical_a = triangular_from_triangle(a, 2, "L", unit_diagonal=True) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.dtrmm("R", "L", "T", "U", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.dtrmm( + b"R", b"L", b"T", b"U", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = alpha * original_b[:2, :] @ logical_a.T + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_ctrmm(prik_blas, f2py_blas): + alpha = np.complex64(1.0 - 0.5j) + a = np.asfortranarray([[2.0 + 1.0j, -1.0 + 2.0j], [np.nan + 1.0j * np.nan, 3.0 - 1.0j]], dtype=np.complex64) + original_b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j], [91.0j, 92.0j]], dtype=np.complex64) + logical_a = triangular_from_triangle(a, 2, "U", unit_diagonal=False) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.ctrmm("L", "U", "C", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.ctrmm( + b"L", b"U", b"C", b"N", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = alpha * logical_a.conj().T @ original_b[:2, :] + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_ztrmm(prik_blas, f2py_blas): + alpha = np.complex128(-0.5 + 0.25j) + nan = np.nan + 1.0j * np.nan + a = np.asfortranarray([[nan, nan], [-1.0 + 2.0j, nan]], dtype=np.complex128) + original_b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j], [91.0j, 92.0j]], dtype=np.complex128) + logical_a = triangular_from_triangle(a, 2, "L", unit_diagonal=True) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.ztrmm("R", "L", "N", "U", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.ztrmm( + b"R", b"L", b"N", b"U", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = alpha * original_b[:2, :] @ logical_a + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_strsm(prik_blas, f2py_blas): + alpha = np.float32(1.5) + a = np.asfortranarray([[2.0, -1.0], [np.nan, 3.0]], dtype=np.float32) + original_b = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [91.0, 92.0]], dtype=np.float32) + logical_a = triangular_from_triangle(a, 2, "U", unit_diagonal=False) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.strsm("L", "U", "N", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.strsm( + b"L", b"U", b"N", b"N", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = np.linalg.solve(logical_a, alpha * original_b[:2, :]) + assert_allclose_for_dtype(logical_a @ prik_b[:2, :], alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(logical_a @ f2py_b[:2, :], alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_dtrsm(prik_blas, f2py_blas): + alpha = np.float64(-0.5) + a = np.asfortranarray([[np.nan, np.nan], [-1.0, np.nan]], dtype=np.float64) + original_b = np.asfortranarray([[1.0, 2.0], [3.0, 4.0], [91.0, 92.0]], dtype=np.float64) + logical_a = triangular_from_triangle(a, 2, "L", unit_diagonal=True) + op_a = logical_a.T + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.dtrsm("R", "L", "T", "U", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.dtrsm( + b"R", b"L", b"T", b"U", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = np.linalg.solve(op_a.T, (alpha * original_b[:2, :]).T).T + assert_allclose_for_dtype(prik_b[:2, :] @ op_a, alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :] @ op_a, alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_ctrsm(prik_blas, f2py_blas): + alpha = np.complex64(1.0 - 0.5j) + a = np.asfortranarray([[2.0 + 1.0j, -1.0 + 2.0j], [np.nan + 1.0j * np.nan, 3.0 - 1.0j]], dtype=np.complex64) + original_b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j], [91.0j, 92.0j]], dtype=np.complex64) + logical_a = triangular_from_triangle(a, 2, "U", unit_diagonal=False) + op_a = logical_a.conj().T + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.ctrsm("L", "U", "C", "N", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.ctrsm( + b"L", b"U", b"C", b"N", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = np.linalg.solve(op_a, alpha * original_b[:2, :]) + assert_allclose_for_dtype(op_a @ prik_b[:2, :], alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(op_a @ f2py_b[:2, :], alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) + + +def test_ztrsm(prik_blas, f2py_blas): + alpha = np.complex128(-0.5 + 0.25j) + nan = np.nan + 1.0j * np.nan + a = np.asfortranarray([[nan, nan], [-1.0 + 2.0j, nan]], dtype=np.complex128) + original_b = np.asfortranarray([[1.0 + 1.0j, 2.0], [3.0 - 1.0j, 4.0 + 0.5j], [91.0j, 92.0j]], dtype=np.complex128) + logical_a = triangular_from_triangle(a, 2, "L", unit_diagonal=True) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = original_b.copy(order="F"), original_b.copy(order="F") + + prik_blas.ztrsm("R", "L", "N", "U", np.int32(2), np.int32(2), alpha, prik_a, np.int32(2), prik_b, np.int32(3)) + f2py_blas.ztrsm( + b"R", b"L", b"N", b"U", np.int32(2), np.int32(2), alpha, f2py_a, f2py_b, lda=np.int32(2), ldb=np.int32(3) + ) + + expected_b = np.linalg.solve(logical_a.T, (alpha * original_b[:2, :]).T).T + assert_allclose_for_dtype(prik_b[:2, :] @ logical_a, alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :] @ logical_a, alpha * original_b[:2, :], operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(f2py_b[:2, :], expected_b, operation_size=2) + assert_allclose_for_dtype(prik_b[:2, :], f2py_b[:2, :], operation_size=2) + np.testing.assert_array_equal(prik_b[2, :], original_b[2, :]) + np.testing.assert_array_equal(f2py_b[2, :], original_b[2, :]) + assert_storage_unchanged(prik_a, a) + assert_storage_unchanged(f2py_a, a) diff --git a/examples/blas/tests/test_routine_coverage.py b/examples/blas/tests/test_routine_coverage.py new file mode 100644 index 000000000..45107bba1 --- /dev/null +++ b/examples/blas/tests/test_routine_coverage.py @@ -0,0 +1,183 @@ +"""Fail closed when the reference source set, inventory, exports, or tests drift.""" + +from __future__ import annotations + +import ast +import re +from pathlib import Path + +import pytest + +from prik.parsers.fortran.parser import parse_fortran_file + +from ..routine_inventory import ( + ALL_ROUTINES, + DIFFERENTIALLY_TESTED_ROUTINES, + EXPLICIT_TEST_NAMES, + PERMANENTLY_SKIPPED_ROUTINES, + PRIK_TESTED_ROUTINES, + ROUTINE_GROUPS, + UNSUPPORTED_ROUTINES, +) + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] +TEST_ROOT = Path(__file__).resolve().parent +EXAMPLE_ROOT = TEST_ROOT.parent +NATIVE_ROOT = EXAMPLE_ROOT / "native" +BLAS_PYF = EXAMPLE_ROOT / "blas.pyf" +FORTRAN_SUFFIXES = frozenset({".f", ".f90", ".f95", ".f03", ".f08", ".for", ".f77", ".ftn"}) +BLAS_SOURCES = tuple( + sorted(path for path in NATIVE_ROOT.iterdir() if path.is_file() and path.suffix.lower() in FORTRAN_SUFFIXES) +) +F2PY_INOUT_ARGUMENTS: dict[str, tuple[str, ...]] = { + "srotg": ("a", "b", "c", "s"), + "drotg": ("a", "b", "c", "s"), + "crotg": ("a", "c", "s"), + "zrotg": ("a", "c", "s"), + "srotmg": ("sd1", "sd2", "sx1", "sparam"), + "drotmg": ("dd1", "dd2", "dx1", "dparam"), +} +PYF_PROCEDURE = re.compile( + r"^\s*(subroutine|function)\s+([a-z]\w*)\s*\(.*?^\s*end\s+\1\s+\2\s*$", + re.IGNORECASE | re.MULTILINE | re.DOTALL, +) + +TEST_MODULES = ( + "test_level1_real.py", + "test_level1_complex.py", + "test_level2_general.py", + "test_level2_symmetric.py", + "test_level2_hermitian.py", + "test_level2_triangular.py", + "test_level2_packed.py", + "test_level2_banded.py", + "test_level3_general.py", + "test_level3_symmetric.py", + "test_level3_hermitian.py", + "test_level3_triangular.py", + "test_auxiliary.py", +) + + +def _pyf_procedures() -> dict[str, str]: + text = BLAS_PYF.read_text(encoding="utf-8") + return {match.group(2).lower(): match.group(0) for match in PYF_PROCEDURE.finditer(text)} + + +def _inout_arguments(block: str) -> set[str]: + return { + argument.strip().lower() + for line in block.splitlines() + if "intent(inout)" in line.lower() and "::" in line + for argument in line.split("::", 1)[1].split(",") + } + + +def test_committed_f2py_signature_matches_source_inventory(): + procedures = _pyf_procedures() + assert len(procedures) == len(BLAS_SOURCES) == 155 + assert set(procedures) == set(_source_routines()) + + +def test_committed_f2py_signature_records_scalar_writebacks(): + observed = { + routine: arguments for routine, block in _pyf_procedures().items() if (arguments := _inout_arguments(block)) + } + assert observed == {routine: set(arguments) for routine, arguments in F2PY_INOUT_ARGUMENTS.items()} + + +def test_f2py_script_compiles_the_signature_and_reuses_the_native_library(): + script = (EXAMPLE_ROOT / "build_f2py.sh").read_text(encoding="utf-8") + assert 'python -m numpy.f2py -c \\\n "$EXAMPLE_WORKSPACE/examples/blas/blas.pyf"' in script + assert '"-L$(dirname "$BLAS_SHARED_LIBRARY")"' in script + assert "-lprik_full_blas" in script + assert "examples/blas/native" not in script + + +def _source_routines() -> tuple[str, ...]: + routines: list[str] = [] + for source in BLAS_SOURCES: + parsed = parse_fortran_file(source.read_text(encoding="utf-8"), filename=source.name) + routines.extend(procedure.name.lower() for procedure in parsed.procedures) + return tuple(routines) + + +def _explicit_test_functions() -> dict[str, tuple[Path, ast.FunctionDef]]: + functions: dict[str, tuple[Path, ast.FunctionDef]] = {} + for filename in TEST_MODULES: + path = TEST_ROOT / filename + tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) + for node in tree.body: + if isinstance(node, ast.FunctionDef) and node.name.startswith("test_"): + assert node.name not in functions, f"duplicate explicitly named test: {node.name}" + functions[node.name] = (path, node) + return functions + + +def test_source_routines_match_the_classified_inventory(): + source_routines = _source_routines() + assert len(BLAS_SOURCES) == 155 + assert len(source_routines) == 155 + assert len(source_routines) == len(set(source_routines)), "source routine names must be unique" + assert len(ALL_ROUTINES) == len(set(ALL_ROUTINES)), "each routine must have exactly one classification" + assert set(source_routines) == set(ALL_ROUTINES) + assert sum(len(routines) for routines in ROUTINE_GROUPS.values()) == 155 + + +def test_f2py_exports_every_expected_routine(f2py_blas): + missing = sorted(routine for routine in ALL_ROUTINES if not callable(getattr(f2py_blas, routine, None))) + assert missing == [] + + +def test_documented_scripts_place_both_wrappers_under_one_build_root(prik_blas, f2py_blas): + prik_root = Path(prik_blas.__file__).resolve().parent.parent + f2py_root = Path(f2py_blas.__file__).resolve().parent.parent + assert prik_root == f2py_root + + +def test_every_routine_has_one_visible_explicit_test(): + functions = _explicit_test_functions() + expected_names = set(EXPLICIT_TEST_NAMES.values()) + missing = sorted(expected_names - functions.keys()) + assert missing == [] + + for routine, test_name in EXPLICIT_TEST_NAMES.items(): + path, node = functions[test_name] + segment = ast.get_source_segment(path.read_text(encoding="utf-8"), node) + assert segment is not None + assert routine in segment, f"{test_name} does not visibly exercise {routine}" + assert "prik" in segment, f"{test_name} does not visibly invoke or validate PRIK" + assert "f2py" in segment, f"{test_name} does not visibly invoke or document f2py" + assert "pytest.skip" not in segment, f"{test_name} silently skips {routine}" + decorator_names = {ast.unparse(decorator) for decorator in node.decorator_list} + assert not any("skip" in decorator for decorator in decorator_names), f"{test_name} skips {routine}" + + +def test_every_routine_has_exactly_one_audited_outcome(): + outcomes = { + "differential success": set(DIFFERENTIALLY_TESTED_ROUTINES), + "unsupported": set(UNSUPPORTED_ROUTINES), + "environmental skip": set(PERMANENTLY_SKIPPED_ROUTINES), + } + for routine in ALL_ROUTINES: + states = [state for state, routines in outcomes.items() if routine in routines] + assert len(states) == 1, f"{routine} has outcome states {states}" + + classified = set().union(*outcomes.values()) + assert classified == set(ALL_ROUTINES) + assert set(ALL_ROUTINES) == PRIK_TESTED_ROUTINES + assert UNSUPPORTED_ROUTINES == {} + assert PERMANENTLY_SKIPPED_ROUTINES == {} + + +def test_documented_coverage_claims_match_inventory(): + readme = " ".join((EXAMPLE_ROOT / "README.md").read_text(encoding="utf-8").split()) + assert len(BLAS_SOURCES) == len(ALL_ROUTINES) == len(PRIK_TESTED_ROUTINES) + assert len(ALL_ROUTINES) == len(DIFFERENTIALLY_TESTED_ROUTINES) + assert f"All {len(ALL_ROUTINES):,} routines are exported and validated through both wrappers" in readme + assert f"The {len(F2PY_INOUT_ARGUMENTS)} rotation routines" in readme + assert f"contains the {len(BLAS_SOURCES):,} files" in readme + assert UNSUPPORTED_ROUTINES == {} + assert PERMANENTLY_SKIPPED_ROUTINES == {} + assert "no unsupported or skipped routines" in readme diff --git a/examples/conftest.py b/examples/conftest.py new file mode 100644 index 000000000..04a0b20d2 --- /dev/null +++ b/examples/conftest.py @@ -0,0 +1,11 @@ +"""Pytest configuration shipped with the copyable native-library examples.""" + +from __future__ import annotations + +import pytest + + +def pytest_configure(config: pytest.Config) -> None: + """Register the repository's two example markers in a copied directory.""" + config.addinivalue_line("markers", "fortran_end_to_end: compiled and called Fortran example") + config.addinivalue_line("markers", "real_library: complete BLAS or LAPACK native-library example") diff --git a/examples/lapack/README.md b/examples/lapack/README.md new file mode 100644 index 000000000..78402785d --- /dev/null +++ b/examples/lapack/README.md @@ -0,0 +1,155 @@ +# Wrap Reference LAPACK with PRIK + +Build the complete Reference LAPACK once, wrap it with PRIK and NumPy f2py, and +validate a reviewed double-precision surface against SciPy and independent +numerical checks. + +PRIK wraps all 2,066 discovered procedures. For focused validation, the suite +selects the 127 `float64` routines exposed by SciPy 1.18.0; raw f2py supports +125 of those source interfaces. All 127 selected routines have explicit +correctness tests, with no unsupported or skipped routines. + +## Requirements + +Install GNU Fortran, `ar`, the LAPACK and BLAS development libraries, and the +pinned Python tools. On Ubuntu: + +```console +sudo apt-get install gfortran liblapack-dev libblas-dev +``` + +Then install the Python tools: + +```console +python3 -m pip install \ + "numpy==2.5.1" "scipy==1.18.0" \ + "meson==1.11.2" "ninja==1.13.0" pytest +``` + +Run the remaining commands from the repository root. + +## Quick start + +Build both wrappers and run the 127-routine comparison: + +```bash +source examples/lapack/build_all.sh +python3 -m pytest -q examples/lapack/tests +``` + +Use `source` so the build paths exported by `build_all.sh` remain available to +the test process. + +## How the build works + +The builder compiles the bundled LAPACK and BLAS sources once. It also links +the installed LAPACK and BLAS libraries for support routines outside the +bundled source set. PRIK and f2py then link the same shared library, so LAPACK +implementation code is not compiled twice. + +The native build also retains its compiler-generated module files in +`LAPACK_MODULE_DIR`. Both generated wrappers use that directory when they +compile. + +`build_all.sh` runs the following two scripts. The commands are shown so you +can reuse or adapt either build independently. + +### Build the PRIK wrapper + + +```bash +export EXAMPLE_WORKSPACE="$PWD" +export LAPACK_BUILD_ROOT="$(mktemp -d)" +export LAPACK_SHARED_LIBRARY="$( + python -m examples.native_library lapack \ + --compiler "$(command -v gfortran)" \ + --jobs 8 +)" +export LAPACK_MODULE_DIR="$(dirname "$LAPACK_SHARED_LIBRARY")/modules" + +mkdir -p "$LAPACK_BUILD_ROOT/prik/generated" +cd "$LAPACK_BUILD_ROOT/prik" +python -m prik "$EXAMPLE_WORKSPACE/examples/lapack/native" \ + --out prik_reference_lapack_example \ + --out-dir "$LAPACK_BUILD_ROOT/prik/generated" \ + --compiler "$(command -v gfortran)" \ + --no-compile-input-sources \ + --native-objects "$LAPACK_SHARED_LIBRARY" \ + -I "$LAPACK_MODULE_DIR" \ + --jobs 8 \ + --wrapper-fortran-flags="-O0 -g0" \ + --wrapper-c-flags="-O0 -g0" +``` + +PRIK reads the complete source tree to generate its Python API. +`--no-compile-input-sources` makes it reuse `LAPACK_SHARED_LIBRARY` instead of +compiling those native sources again. + +### Build the f2py comparison wrapper + + +```bash +cd "$EXAMPLE_WORKSPACE" +export LAPACK_F2PY_ROOT="$LAPACK_BUILD_ROOT/f2py" +mkdir -p "$LAPACK_F2PY_ROOT/generated" +cd "$LAPACK_F2PY_ROOT" + +export FC="$(command -v gfortran)" +export F77="$FC" +export F90="$FC" +export FFLAGS="-O0" +export F90FLAGS="-O0" +export LDFLAGS="${LDFLAGS:+$LDFLAGS }-Wl,-rpath,$(dirname "$LAPACK_SHARED_LIBRARY")" + +python -m numpy.f2py -c \ + "$EXAMPLE_WORKSPACE/examples/lapack/lapack.pyf" \ + "-L$(dirname "$LAPACK_SHARED_LIBRARY")" \ + -lprik_full_lapack \ + --f2cmap "$EXAMPLE_WORKSPACE/examples/lapack/lapack.f2cmap" \ + --build-dir "$LAPACK_F2PY_ROOT/generated" \ + --f77flags=-O0 \ + --f90flags="-O0 -I$LAPACK_MODULE_DIR" \ + --opt=-O0 +``` + +The committed reviewed [`lapack.pyf`](lapack.pyf) defines the 125-routine f2py +comparison surface and exposes `la_constants`. f2py compiles only its generated +wrapper and reuses the native library and module directory. + +## Run focused tests + +After the quick-start build, run one family or routine: + +```bash +python3 -m pytest -q examples/lapack/tests/test_linear_general.py +python3 -m pytest -q \ + examples/lapack/tests/test_linear_general.py::test_dgesv_solves_general_system +python3 -m pytest -q examples/lapack/tests -k dgesvd +``` + +## What is validated + +PRIK preserves native argument order, storage, indexes, and scalar writebacks. +The 9 scalar-writeback routines omit Fortran `intent` for scalar outputs. +[`lapack.pyf`](lapack.pyf) records them as `intent(inout)`, so f2py receives +typed NumPy 0-D arrays. PRIK returns the same writebacks directly. + +The tests cover linear solves, factorizations, eigenproblems, singular values, +banded and packed layouts, workspaces, pivots, untouched storage, and `INFO`. +Equivalent decompositions are checked with mathematical invariants rather than +byte equality. + +The committed [`lapack.pyf`](lapack.pyf) excludes `dgees` and `dgges` because +f2py 2.5.1 generates incomplete declarations for their selection callbacks. +Their tests exercise PRIK and SciPy, then independently verify the resulting +Schur decompositions. + +## Sources and license + +[`native/`](native/) owns 2,062 LAPACK implementation sources: 2,061 from +Netlib LAPACK 3.12.1 plus the project-local `dlamch.f`. BLAS dependencies come +from [`../blas/native/`](../blas/native/) and are not duplicated here. The +audited upstream archive has SHA-256 +`37b00c90947488521f475b5a187fff4da4a5cfe61b525efcacf7a97f39a45ec6`. +See the [Reference LAPACK site](https://www.netlib.org/lapack/) and its +[three-clause BSD-style license](https://www.netlib.org/lapack/LICENSE.txt). diff --git a/examples/lapack/__init__.py b/examples/lapack/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/lapack/build_all.sh b/examples/lapack/build_all.sh new file mode 100644 index 000000000..119576aff --- /dev/null +++ b/examples/lapack/build_all.sh @@ -0,0 +1,4 @@ +source examples/lapack/build_prik.sh +source "$EXAMPLE_WORKSPACE/examples/lapack/build_f2py.sh" +cd "$EXAMPLE_WORKSPACE" +export PYTHONPATH="$LAPACK_BUILD_ROOT/prik:$LAPACK_F2PY_ROOT${PYTHONPATH:+:$PYTHONPATH}" diff --git a/examples/lapack/build_f2py.sh b/examples/lapack/build_f2py.sh new file mode 100644 index 000000000..26ecc63ad --- /dev/null +++ b/examples/lapack/build_f2py.sh @@ -0,0 +1,21 @@ +cd "$EXAMPLE_WORKSPACE" +export LAPACK_F2PY_ROOT="$LAPACK_BUILD_ROOT/f2py" +mkdir -p "$LAPACK_F2PY_ROOT/generated" +cd "$LAPACK_F2PY_ROOT" + +export FC="$(command -v gfortran)" +export F77="$FC" +export F90="$FC" +export FFLAGS="-O0" +export F90FLAGS="-O0" +export LDFLAGS="${LDFLAGS:+$LDFLAGS }-Wl,-rpath,$(dirname "$LAPACK_SHARED_LIBRARY")" + +python -m numpy.f2py -c \ + "$EXAMPLE_WORKSPACE/examples/lapack/lapack.pyf" \ + "-L$(dirname "$LAPACK_SHARED_LIBRARY")" \ + -lprik_full_lapack \ + --f2cmap "$EXAMPLE_WORKSPACE/examples/lapack/lapack.f2cmap" \ + --build-dir "$LAPACK_F2PY_ROOT/generated" \ + --f77flags=-O0 \ + --f90flags="-O0 -I$LAPACK_MODULE_DIR" \ + --opt=-O0 diff --git a/examples/lapack/build_prik.sh b/examples/lapack/build_prik.sh new file mode 100644 index 000000000..6b85ecb38 --- /dev/null +++ b/examples/lapack/build_prik.sh @@ -0,0 +1,21 @@ +export EXAMPLE_WORKSPACE="$PWD" +export LAPACK_BUILD_ROOT="$(mktemp -d)" +export LAPACK_SHARED_LIBRARY="$( + python -m examples.native_library lapack \ + --compiler "$(command -v gfortran)" \ + --jobs 8 +)" +export LAPACK_MODULE_DIR="$(dirname "$LAPACK_SHARED_LIBRARY")/modules" + +mkdir -p "$LAPACK_BUILD_ROOT/prik/generated" +cd "$LAPACK_BUILD_ROOT/prik" +python -m prik "$EXAMPLE_WORKSPACE/examples/lapack/native" \ + --out prik_reference_lapack_example \ + --out-dir "$LAPACK_BUILD_ROOT/prik/generated" \ + --compiler "$(command -v gfortran)" \ + --no-compile-input-sources \ + --native-objects "$LAPACK_SHARED_LIBRARY" \ + -I "$LAPACK_MODULE_DIR" \ + --jobs 8 \ + --wrapper-fortran-flags="-O0 -g0" \ + --wrapper-c-flags="-O0 -g0" diff --git a/examples/lapack/ci/__init__.py b/examples/lapack/ci/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/lapack/ci/full_surface.py b/examples/lapack/ci/full_surface.py new file mode 100644 index 000000000..0552e1d39 --- /dev/null +++ b/examples/lapack/ci/full_surface.py @@ -0,0 +1,54 @@ +"""Maintainer-only complete-surface checks that reuse the LAPACK example build.""" + +from __future__ import annotations + +from pathlib import Path + +import pytest + +from ..routine_inventory import EXPECTED_LAPACK_PROCEDURES +from examples.lapack.tests.helpers import assert_runtime_smoke +from prik.parsers.fortran.parser import parse_fortran_file +from prik.pipeline.preprocessing import PreprocessingConfig, preprocess_source + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] +NATIVE_ROOT = Path(__file__).resolve().parents[1] / "native" +FORTRAN_SUFFIXES = {".f", ".f90", ".f95", ".f03", ".f08", ".for", ".f77", ".ftn"} +PREPROCESSED_FORTRAN_SUFFIXES = {suffix.upper() for suffix in FORTRAN_SUFFIXES} + + +def _source_for_parser(path: Path) -> str: + if path.suffix in PREPROCESSED_FORTRAN_SUFFIXES: + return preprocess_source( + path, + language="fortran", + config=PreprocessingConfig(mode="compiler", compiler="gfortran"), + ).source + return path.read_text(encoding="utf-8") + + +def _source_procedure_exports() -> set[tuple[str | None, str]]: + expected: set[tuple[str | None, str]] = set() + for path in sorted(NATIVE_ROOT.iterdir()): + if not path.is_file() or path.suffix.lower() not in FORTRAN_SUFFIXES: + continue + parsed = parse_fortran_file(_source_for_parser(path), filename=path.name) + expected.update((None, procedure.name.lower()) for procedure in parsed.procedures) + for module in parsed.modules: + expected.update((module.name.lower(), procedure.name.lower()) for procedure in module.procedures) + return expected + + +def test_ci_complete_prik_surface_reuses_example_extension(prik_lapack): + expected = _source_procedure_exports() + assert len(expected) == EXPECTED_LAPACK_PROCEDURES + assert all(getattr(prik_lapack, name, None) is not None for name in ("la_constants", "la_xisnan")) + + missing = [] + for namespace, name in sorted(expected, key=lambda item: (item[0] or "", item[1])): + owner = prik_lapack if namespace is None else getattr(prik_lapack, namespace, None) + if owner is None or not callable(getattr(owner, name, None)): + missing.append(".".join(filter(None, (namespace, name)))) + assert missing == [] + assert_runtime_smoke(prik_lapack) diff --git a/examples/lapack/conftest.py b/examples/lapack/conftest.py new file mode 100644 index 000000000..2b43a8f07 --- /dev/null +++ b/examples/lapack/conftest.py @@ -0,0 +1,40 @@ +"""Import fixtures for the wrappers produced by ``build_all.sh``.""" + +import importlib +import os +import sys + +import pytest + +from .routine_inventory import SCIPY_VERSION + + +@pytest.fixture(scope="session") +def prik_lapack(): + """Return the already-built PRIK LAPACK module.""" + old_flags = sys.getdlopenflags() + sys.setdlopenflags(getattr(os, "RTLD_LAZY", old_flags) | getattr(os, "RTLD_GLOBAL", 0)) + try: + return importlib.import_module("prik_reference_lapack_example") + finally: + sys.setdlopenflags(old_flags) + + +@pytest.fixture(scope="session") +def f2py_lapack(): + """Return the already-built f2py LAPACK module.""" + old_flags = sys.getdlopenflags() + sys.setdlopenflags(getattr(os, "RTLD_LAZY", old_flags) | getattr(os, "RTLD_GLOBAL", 0)) + try: + return importlib.import_module("f2py_reference_lapack_example") + finally: + sys.setdlopenflags(old_flags) + + +@pytest.fixture(scope="session") +def scipy_lapack(): + """Return the pinned SciPy low-level LAPACK module.""" + scipy = pytest.importorskip("scipy") + if scipy.__version__ != SCIPY_VERSION: + pytest.fail(f"expected SciPy {SCIPY_VERSION}, found {scipy.__version__}") + return importlib.import_module("scipy.linalg.lapack") diff --git a/examples/lapack/lapack.f2cmap b/examples/lapack/lapack.f2cmap new file mode 100644 index 000000000..3fe0a8866 --- /dev/null +++ b/examples/lapack/lapack.f2cmap @@ -0,0 +1 @@ +{'real': {'wp': 'double'}} diff --git a/examples/lapack/lapack.pyf b/examples/lapack/lapack.pyf new file mode 100644 index 000000000..32cfaa817 --- /dev/null +++ b/examples/lapack/lapack.pyf @@ -0,0 +1,1638 @@ +! -*- f90 -*- +! Note: the context of this file is case sensitive. + +python module f2py_reference_lapack_example + interface + module la_constants + integer, parameter,optional :: sp=kind(1.e0) + real(kind=4), parameter,optional :: szero=0.0_sp + real(kind=4), parameter,optional :: shalf=0.5_sp + real(kind=4), parameter,optional :: sone=1.0_sp + real(kind=4), parameter,optional :: stwo=2.0_sp + real(kind=4), parameter,optional :: sthree=3.0_sp + real(kind=4), parameter,optional :: sfour=4.0_sp + real(kind=4), parameter,optional :: seight=8.0_sp + real(kind=4), parameter,optional :: sten=10.0_sp + complex(kind=4), parameter,optional :: czero=(0.0_sp, 0.0_sp) + complex(kind=4), parameter,optional :: chalf=(0.5_sp, 0.0_sp) + complex(kind=4), parameter,optional :: cone=(1.0_sp, 0.0_sp) + character*1, parameter,optional :: sprefix='s' + character*1, parameter,optional :: cprefix='c' + real(kind=4), parameter,optional :: sulp=epsilon(0._sp) + real(kind=4), parameter,optional,depend(sulp) :: seps=sulp*0.5_sp + real(kind=4), parameter,optional,depend(sp) :: ssafmin=real(radix(0._sp),sp)**max(minexponent(0._sp)-1,1-maxexponent(0._sp)) + real(kind=4), parameter,optional,depend(sone,ssafmin,sp) :: ssafmax=1.0 + real(kind=4), parameter,optional,depend(sulp,ssafmin,sp) :: ssmlnum=1.0 + real(kind=4), parameter,optional,depend(sulp,ssafmax,sone,ssafmin,sp) :: sbignum=4.0 + real(kind=4), parameter,optional,depend(ssmlnum,sulp,ssafmin,sp) :: srtmin=sqrt(ssmlnum) + real(kind=4), parameter,optional,depend(sbignum,sulp,ssafmax,sone,ssafmin,sp) :: srtmax=sqrt(sbignum) + real(kind=4), parameter,optional,depend(sp) :: stsml=real(radix(0._sp), sp)**ceiling((minexponent(0._sp)-1)*0.5_sp) + real(kind=4), parameter,optional,depend(sp) :: stbig=real(radix(0._sp), sp)**floor((maxexponent(0._sp)-digits(0._sp)+1)*0.5_sp) + real(kind=4), parameter,optional,depend(sp) :: sssml=real(radix(0._sp), sp)**(-floor((minexponent(0._sp)-digits(0._sp))*0.5_sp)) + real(kind=4), parameter,optional,depend(sp) :: ssbig=real(radix(0._sp), sp)**(-ceiling((maxexponent(0._sp)+digits(0._sp)-1)*0.5_sp)) + integer, parameter,optional :: dp=kind(1.d0) + real(kind=8), parameter,optional :: dzero=0.0_dp + real(kind=8), parameter,optional :: dhalf=0.5_dp + real(kind=8), parameter,optional :: done=1.0_dp + real(kind=8), parameter,optional :: dtwo=2.0_dp + real(kind=8), parameter,optional :: dthree=3.0_dp + real(kind=8), parameter,optional :: dfour=4.0_dp + real(kind=8), parameter,optional :: deight=8.0_dp + real(kind=8), parameter,optional :: dten=10.0_dp + complex(kind=8), parameter,optional :: zzero=(0.0_dp, 0.0_dp) + complex(kind=8), parameter,optional :: zhalf=(0.5_dp, 0.0_dp) + complex(kind=8), parameter,optional :: zone=(1.0_dp, 0.0_dp) + character*1, parameter,optional :: dprefix='d' + character*1, parameter,optional :: zprefix='z' + real(kind=8), parameter,optional :: dulp=epsilon(0._dp) + real(kind=8), parameter,optional,depend(dulp) :: deps=dulp*0.5_dp + real(kind=8), parameter,optional,depend(dp) :: dsafmin=real(radix(0._dp),dp)**max(minexponent(0._dp)-1,1-maxexponent(0._dp)) + real(kind=8), parameter,optional,depend(done,dsafmin,dp) :: dsafmax=1.0 + real(kind=8), parameter,optional,depend(dulp,dsafmin,dp) :: dsmlnum=1.0 + real(kind=8), parameter,optional,depend(dulp,dsafmax,done,dsafmin,dp) :: dbignum=4.0 + real(kind=8), parameter,optional,depend(dsmlnum,dulp,dsafmin,dp) :: drtmin=sqrt(dsmlnum) + real(kind=8), parameter,optional,depend(dbignum,dulp,dsafmax,done,dsafmin,dp) :: drtmax=sqrt(dbignum) + real(kind=8), parameter,optional,depend(dp) :: dtsml=real(radix(0._dp), dp)**ceiling((minexponent(0._dp)-1)*0.5_dp) + real(kind=8), parameter,optional,depend(dp) :: dtbig=real(radix(0._dp), dp)**floor((maxexponent(0._dp)-digits(0._dp)+1)*0.5_dp) + real(kind=8), parameter,optional,depend(dp) :: dssml=real(radix(0._dp), dp)**(-floor((minexponent(0._dp)-digits(0._dp))*0.5_dp)) + real(kind=8), parameter,optional,depend(dp) :: dsbig=real(radix(0._dp), dp)**(-ceiling((maxexponent(0._dp)+digits(0._dp)-1)*0.5_dp)) + end module la_constants + function dlamch(cmach) + character :: cmach + double precision :: dlamch + end function dlamch + function dlangb(norm,n,kl,ku,ab,ldab,work) + character :: norm + integer :: n + integer :: kl + integer :: ku + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + double precision dimension(*) :: work + double precision :: dlangb + end function dlangb + function dlange(norm,m,n,a,lda,work) + character :: norm + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: work + double precision :: dlange + end function dlange + function dlantr(norm,uplo,diag,m,n,a,lda,work) + character :: norm + character :: uplo + character :: diag + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: work + double precision :: dlantr + end function dlantr + subroutine dlarf(side,m,n,v,incv,tau,c,ldc,work) + character :: side + integer :: m + integer :: n + double precision dimension(*) :: v + integer :: incv + double precision :: tau + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + double precision dimension(*) :: work + end subroutine dlarf + subroutine dlarfg(n,alpha,x,incx,tau) + integer :: n + double precision intent(inout) :: alpha + double precision dimension(*) :: x + integer :: incx + double precision intent(inout) :: tau + end subroutine dlarfg + subroutine dlartg(f,g,c,s,r) + use la_constants, only: wp=>dp,zero=>dzero,half=>dhalf,one=>done,safmin=>dsafmin,safmax=>dsafmax + real(kind=wp) :: f + real(kind=wp) :: g + real(kind=wp) intent(inout) :: c + real(kind=wp) intent(inout) :: s + real(kind=wp) intent(inout) :: r + end subroutine dlartg + subroutine dlaswp(n,a,lda,k1,k2,ipiv,incx) + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: k1 + integer :: k2 + integer dimension(*) :: ipiv + integer :: incx + end subroutine dlaswp + subroutine dgecon(norm,n,a,lda,anorm,rcond,work,iwork,info) + character :: norm + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision :: anorm + double precision intent(inout) :: rcond + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer intent(inout) :: info + end subroutine dgecon + subroutine dgeequ(m,n,a,lda,r,c,rowcnd,colcnd,amax,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: r + double precision dimension(*) :: c + double precision :: rowcnd + double precision :: colcnd + double precision :: amax + integer :: info + end subroutine dgeequ + subroutine dgeequb(m,n,a,lda,r,c,rowcnd,colcnd,amax,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: r + double precision dimension(*) :: c + double precision :: rowcnd + double precision :: colcnd + double precision :: amax + integer :: info + end subroutine dgeequb + subroutine dgesc2(n,a,lda,rhs,ipiv,jpiv,scale) + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: rhs + integer dimension(*) :: ipiv + integer dimension(*) :: jpiv + double precision :: scale + end subroutine dgesc2 + subroutine dgesv(n,nrhs,a,lda,ipiv,b,ldb,info) + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dgesv + subroutine dgesvx(fact,trans,n,nrhs,a,lda,af,ldaf,ipiv,equed,r,c,b,ldb,x,ldx,rcond,ferr,berr,work,iwork,info) + character :: fact + character :: trans + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldaf,*) :: af + integer, optional,check(shape(af, 0) == ldaf),depend(af) :: ldaf=shape(af, 0) + integer dimension(*) :: ipiv + character :: equed + double precision dimension(*) :: r + double precision dimension(*) :: c + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldx,*) :: x + integer, optional,check(shape(x, 0) == ldx),depend(x) :: ldx=shape(x, 0) + double precision :: rcond + double precision dimension(*) :: ferr + double precision dimension(*) :: berr + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer :: info + end subroutine dgesvx + subroutine dgetc2(n,a,lda,ipiv,jpiv,info) + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + integer dimension(*) :: jpiv + integer :: info + end subroutine dgetc2 + subroutine dgetrf(m,n,a,lda,ipiv,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + integer :: info + end subroutine dgetrf + subroutine dgetri(n,a,lda,ipiv,work,lwork,info) + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgetri + subroutine dgetrs(trans,n,nrhs,a,lda,ipiv,b,ldb,info) + character :: trans + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dgetrs + subroutine dsycon(uplo,n,a,lda,ipiv,anorm,rcond,work,iwork,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision :: anorm + double precision intent(inout) :: rcond + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer intent(inout) :: info + end subroutine dsycon + subroutine dsyconv(uplo,way,n,a,lda,ipiv,e,info) + character :: uplo + character :: way + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(*) :: e + integer :: info + end subroutine dsyconv + subroutine dsyequb(uplo,n,a,lda,s,scond,amax,work,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: s + double precision :: scond + double precision :: amax + double precision dimension(*) :: work + integer :: info + end subroutine dsyequb + subroutine dsysv(uplo,n,nrhs,a,lda,ipiv,b,ldb,work,lwork,info) + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dsysv + subroutine dsysvx(fact,uplo,n,nrhs,a,lda,af,ldaf,ipiv,b,ldb,x,ldx,rcond,ferr,berr,work,lwork,iwork,info) + character :: fact + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldaf,*) :: af + integer, optional,check(shape(af, 0) == ldaf),depend(af) :: ldaf=shape(af, 0) + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldx,*) :: x + integer, optional,check(shape(x, 0) == ldx),depend(x) :: ldx=shape(x, 0) + double precision :: rcond + double precision dimension(*) :: ferr + double precision dimension(*) :: berr + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: info + end subroutine dsysvx + subroutine dsytf2(uplo,n,a,lda,ipiv,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + integer :: info + end subroutine dsytf2 + subroutine dsytrf(uplo,n,a,lda,ipiv,work,lwork,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dsytrf + subroutine dsytri(uplo,n,a,lda,ipiv,work,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(*) :: work + integer :: info + end subroutine dsytri + subroutine dsytrs(uplo,n,nrhs,a,lda,ipiv,b,ldb,info) + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dsytrs + subroutine dlauum(uplo,n,a,lda,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: info + end subroutine dlauum + subroutine dpftrf(transr,uplo,n,a,info) + character :: transr + character :: uplo + integer :: n + double precision dimension(*) :: a + integer :: info + end subroutine dpftrf + subroutine dpftri(transr,uplo,n,a,info) + character :: transr + character :: uplo + integer :: n + double precision dimension(*) :: a + integer :: info + end subroutine dpftri + subroutine dpftrs(transr,uplo,n,nrhs,a,b,ldb,info) + character :: transr + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(*) :: a + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dpftrs + subroutine dpocon(uplo,n,a,lda,anorm,rcond,work,iwork,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision :: anorm + double precision intent(inout) :: rcond + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer intent(inout) :: info + end subroutine dpocon + subroutine dposv(uplo,n,nrhs,a,lda,b,ldb,info) + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dposv + subroutine dposvx(fact,uplo,n,nrhs,a,lda,af,ldaf,equed,s,b,ldb,x,ldx,rcond,ferr,berr,work,iwork,info) + character :: fact + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldaf,*) :: af + integer, optional,check(shape(af, 0) == ldaf),depend(af) :: ldaf=shape(af, 0) + character :: equed + double precision dimension(*) :: s + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldx,*) :: x + integer, optional,check(shape(x, 0) == ldx),depend(x) :: ldx=shape(x, 0) + double precision :: rcond + double precision dimension(*) :: ferr + double precision dimension(*) :: berr + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer :: info + end subroutine dposvx + subroutine dpotrf(uplo,n,a,lda,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: info + end subroutine dpotrf + subroutine dpotri(uplo,n,a,lda,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: info + end subroutine dpotri + subroutine dpotrs(uplo,n,nrhs,a,lda,b,ldb,info) + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dpotrs + subroutine dppcon(uplo,n,ap,anorm,rcond,work,iwork,info) + character :: uplo + integer :: n + double precision dimension(*) :: ap + double precision :: anorm + double precision intent(inout) :: rcond + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer intent(inout) :: info + end subroutine dppcon + subroutine dppsv(uplo,n,nrhs,ap,b,ldb,info) + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(*) :: ap + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dppsv + subroutine dpptrf(uplo,n,ap,info) + character :: uplo + integer :: n + double precision dimension(*) :: ap + integer :: info + end subroutine dpptrf + subroutine dpptri(uplo,n,ap,info) + character :: uplo + integer :: n + double precision dimension(*) :: ap + integer :: info + end subroutine dpptri + subroutine dpptrs(uplo,n,nrhs,ap,b,ldb,info) + character :: uplo + integer :: n + integer :: nrhs + double precision dimension(*) :: ap + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dpptrs + subroutine dpstf2(uplo,n,a,lda,piv,rank_bn,tol,work,info) + character :: uplo + integer, optional,check(shape(piv, 0) == n),depend(piv) :: n=shape(piv, 0) + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(n) :: piv + integer :: rank_bn + double precision :: tol + double precision dimension(2 * n),depend(n) :: work + integer :: info + end subroutine dpstf2 + subroutine dpstrf(uplo,n,a,lda,piv,rank_bn,tol,work,info) + character :: uplo + integer, optional,check(shape(piv, 0) == n),depend(piv) :: n=shape(piv, 0) + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(n) :: piv + integer :: rank_bn + double precision :: tol + double precision dimension(2 * n),depend(n) :: work + integer :: info + end subroutine dpstrf + subroutine dsfrk(transr,uplo,trans,n,k,alpha,a,lda,beta,c) + character :: transr + character :: uplo + character :: trans + integer :: n + integer :: k + double precision :: alpha + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision :: beta + double precision dimension(*) :: c + end subroutine dsfrk + subroutine dgbcon(norm,n,kl,ku,ab,ldab,ipiv,anorm,rcond,work,iwork,info) + character :: norm + integer :: n + integer :: kl + integer :: ku + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + integer dimension(*) :: ipiv + double precision :: anorm + double precision intent(inout) :: rcond + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer intent(inout) :: info + end subroutine dgbcon + subroutine dgbsv(n,kl,ku,nrhs,ab,ldab,ipiv,b,ldb,info) + integer :: n + integer :: kl + integer :: ku + integer :: nrhs + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dgbsv + subroutine dgbtrf(m,n,kl,ku,ab,ldab,ipiv,info) + integer :: m + integer :: n + integer :: kl + integer :: ku + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + integer dimension(*) :: ipiv + integer :: info + end subroutine dgbtrf + subroutine dgbtrs(trans,n,kl,ku,nrhs,ab,ldab,ipiv,b,ldb,info) + character :: trans + integer :: n + integer :: kl + integer :: ku + integer :: nrhs + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dgbtrs + subroutine dgtcon(norm,n,dl,d,du,du2,ipiv,anorm,rcond,work,iwork,info) + character :: norm + integer :: n + double precision dimension(*) :: dl + double precision dimension(*) :: d + double precision dimension(*) :: du + double precision dimension(*) :: du2 + integer dimension(*) :: ipiv + double precision :: anorm + double precision intent(inout) :: rcond + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer intent(inout) :: info + end subroutine dgtcon + subroutine dgtsv(n,nrhs,dl,d,du,b,ldb,info) + integer :: n + integer :: nrhs + double precision dimension(*) :: dl + double precision dimension(*) :: d + double precision dimension(*) :: du + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dgtsv + subroutine dgtsvx(fact,trans,n,nrhs,dl,d,du,dlf,df,duf,du2,ipiv,b,ldb,x,ldx,rcond,ferr,berr,work,iwork,info) + character :: fact + character :: trans + integer :: n + integer :: nrhs + double precision dimension(*) :: dl + double precision dimension(*) :: d + double precision dimension(*) :: du + double precision dimension(*) :: dlf + double precision dimension(*) :: df + double precision dimension(*) :: duf + double precision dimension(*) :: du2 + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldx,*) :: x + integer, optional,check(shape(x, 0) == ldx),depend(x) :: ldx=shape(x, 0) + double precision :: rcond + double precision dimension(*) :: ferr + double precision dimension(*) :: berr + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer :: info + end subroutine dgtsvx + subroutine dgttrf(n,dl,d,du,du2,ipiv,info) + integer :: n + double precision dimension(*) :: dl + double precision dimension(*) :: d + double precision dimension(*) :: du + double precision dimension(*) :: du2 + integer dimension(*) :: ipiv + integer :: info + end subroutine dgttrf + subroutine dgttrs(trans,n,nrhs,dl,d,du,du2,ipiv,b,ldb,info) + character :: trans + integer :: n + integer :: nrhs + double precision dimension(*) :: dl + double precision dimension(*) :: d + double precision dimension(*) :: du + double precision dimension(*) :: du2 + integer dimension(*) :: ipiv + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dgttrs + subroutine dpbsv(uplo,n,kd,nrhs,ab,ldab,b,ldb,info) + character :: uplo + integer :: n + integer :: kd + integer :: nrhs + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dpbsv + subroutine dpbtrf(uplo,n,kd,ab,ldab,info) + character :: uplo + integer :: n + integer :: kd + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + integer :: info + end subroutine dpbtrf + subroutine dpbtrs(uplo,n,kd,nrhs,ab,ldab,b,ldb,info) + character :: uplo + integer :: n + integer :: kd + integer :: nrhs + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dpbtrs + subroutine dptsv(n,nrhs,d,e,b,ldb,info) + integer :: n + integer :: nrhs + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dptsv + subroutine dptsvx(fact,n,nrhs,d,e,df,ef,b,ldb,x,ldx,rcond,ferr,berr,work,info) + character :: fact + integer :: n + integer :: nrhs + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision dimension(*) :: df + double precision dimension(*) :: ef + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldx,*) :: x + integer, optional,check(shape(x, 0) == ldx),depend(x) :: ldx=shape(x, 0) + double precision :: rcond + double precision dimension(*) :: ferr + double precision dimension(*) :: berr + double precision dimension(*) :: work + integer :: info + end subroutine dptsvx + subroutine dpttrf(n,d,e,info) + integer :: n + double precision dimension(*) :: d + double precision dimension(*) :: e + integer :: info + end subroutine dpttrf + subroutine dpttrs(n,nrhs,d,e,b,ldb,info) + integer :: n + integer :: nrhs + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dpttrs + subroutine dtbtrs(uplo,trans,diag,n,kd,nrhs,ab,ldab,b,ldb,info) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: kd + integer :: nrhs + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dtbtrs + subroutine dtfsm(transr,side,uplo,trans,diag,m,n,alpha,a,b,ldb) + character :: transr + character :: side + character :: uplo + character :: trans + character :: diag + integer :: m + integer :: n + double precision :: alpha + double precision dimension(*) :: a + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + end subroutine dtfsm + subroutine dtfttp(transr,uplo,n,arf,ap,info) + character :: transr + character :: uplo + integer :: n + double precision dimension(*) :: arf + double precision dimension(*) :: ap + integer :: info + end subroutine dtfttp + subroutine dtfttr(transr,uplo,n,arf,a,lda,info) + character :: transr + character :: uplo + integer :: n + double precision dimension(*) :: arf + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: info + end subroutine dtfttr + subroutine dtpttf(transr,uplo,n,ap,arf,info) + character :: transr + character :: uplo + integer :: n + double precision dimension(*) :: ap + double precision dimension(*) :: arf + integer :: info + end subroutine dtpttf + subroutine dtpttr(uplo,n,ap,a,lda,info) + character :: uplo + integer :: n + double precision dimension(*) :: ap + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: info + end subroutine dtpttr + subroutine dtrcon(norm,uplo,diag,n,a,lda,rcond,work,iwork,info) + character :: norm + character :: uplo + character :: diag + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision intent(inout) :: rcond + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer intent(inout) :: info + end subroutine dtrcon + subroutine dtrtri(uplo,diag,n,a,lda,info) + character :: uplo + character :: diag + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: info + end subroutine dtrtri + subroutine dtrtrs(uplo,trans,diag,n,nrhs,a,lda,b,ldb,info) + character :: uplo + character :: trans + character :: diag + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dtrtrs + subroutine dtrttf(transr,uplo,n,a,lda,arf,info) + character :: transr + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: arf + integer :: info + end subroutine dtrttf + subroutine dtrttp(uplo,n,a,lda,ap,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: ap + integer :: info + end subroutine dtrttp + subroutine dgels(trans,m,n,nrhs,a,lda,b,ldb,work,lwork,info) + character :: trans + integer :: m + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgels + subroutine dgelsd(m,n,nrhs,a,lda,b,ldb,s,rcond,rank_bn,work,lwork,iwork,info) + integer :: m + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: s + double precision :: rcond + integer :: rank_bn + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: info + end subroutine dgelsd + subroutine dgelss(m,n,nrhs,a,lda,b,ldb,s,rcond,rank_bn,work,lwork,info) + integer :: m + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: s + double precision :: rcond + integer :: rank_bn + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgelss + subroutine dgelsy(m,n,nrhs,a,lda,b,ldb,jpvt,rcond,rank_bn,work,lwork,info) + integer :: m + integer :: n + integer :: nrhs + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer dimension(*) :: jpvt + double precision :: rcond + integer :: rank_bn + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgelsy + subroutine dgglse(m,n,p,a,lda,b,ldb,c,d,x,work,lwork,info) + integer :: m + integer :: n + integer :: p + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: c + double precision dimension(*) :: d + double precision dimension(*) :: x + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgglse + subroutine dgemqrt(side,trans,m,n,k,nb,v,ldv,t,ldt,c,ldc,work,info) + character :: side + character :: trans + integer :: m + integer :: n + integer :: k + integer :: nb + double precision dimension(ldv,*) :: v + integer, optional,check(shape(v, 0) == ldv),depend(v) :: ldv=shape(v, 0) + double precision dimension(ldt,*) :: t + integer, optional,check(shape(t, 0) == ldt),depend(t) :: ldt=shape(t, 0) + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + double precision dimension(*) :: work + integer :: info + end subroutine dgemqrt + subroutine dgeqp3(m,n,a,lda,jpvt,tau,work,lwork,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer dimension(*) :: jpvt + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgeqp3 + subroutine dgeqrf(m,n,a,lda,tau,work,lwork,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgeqrf + subroutine dgeqrfp(m,n,a,lda,tau,work,lwork,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgeqrfp + subroutine dgeqrt(m,n,nb,a,lda,t,ldt,work,info) + integer :: m + integer :: n + integer :: nb + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldt,*) :: t + integer, optional,check(shape(t, 0) == ldt),depend(t) :: ldt=shape(t, 0) + double precision dimension(*) :: work + integer :: info + end subroutine dgeqrt + subroutine dgerqf(m,n,a,lda,tau,work,lwork,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgerqf + subroutine dorgqr(m,n,k,a,lda,tau,work,lwork,info) + integer :: m + integer :: n + integer :: k + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dorgqr + subroutine dorgrq(m,n,k,a,lda,tau,work,lwork,info) + integer :: m + integer :: n + integer :: k + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dorgrq + subroutine dormqr(side,trans,m,n,k,a,lda,tau,c,ldc,work,lwork,info) + character :: side + character :: trans + integer :: m + integer :: n + integer :: k + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dormqr + subroutine dormrz(side,trans,m,n,k,l,a,lda,tau,c,ldc,work,lwork,info) + character :: side + character :: trans + integer :: m + integer :: n + integer :: k + integer :: l + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dormrz + subroutine dtpmqrt(side,trans,m,n,k,l,nb,v,ldv,t,ldt,a,lda,b,ldb,work,info) + character :: side + character :: trans + integer :: m + integer :: n + integer :: k + integer :: l + integer :: nb + double precision dimension(ldv,*) :: v + integer, optional,check(shape(v, 0) == ldv),depend(v) :: ldv=shape(v, 0) + double precision dimension(ldt,*) :: t + integer, optional,check(shape(t, 0) == ldt),depend(t) :: ldt=shape(t, 0) + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: work + integer :: info + end subroutine dtpmqrt + subroutine dtpqrt(m,n,l,nb,a,lda,b,ldb,t,ldt,work,info) + integer :: m + integer :: n + integer :: l + integer :: nb + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldt,*) :: t + integer, optional,check(shape(t, 0) == ldt),depend(t) :: ldt=shape(t, 0) + double precision dimension(*) :: work + integer :: info + end subroutine dtpqrt + subroutine dtzrzf(m,n,a,lda,tau,work,lwork,info) + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dtzrzf + subroutine dgebal(job,n,a,lda,ilo,ihi,scale,info) + character :: job + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + integer :: ilo + integer :: ihi + double precision dimension(*) :: scale + integer :: info + end subroutine dgebal + subroutine dgeev(jobvl,jobvr,n,a,lda,wr,wi,vl,ldvl,vr,ldvr,work,lwork,info) + character :: jobvl + character :: jobvr + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: wr + double precision dimension(*) :: wi + double precision dimension(ldvl,*) :: vl + integer, optional,check(shape(vl, 0) == ldvl),depend(vl) :: ldvl=shape(vl, 0) + double precision dimension(ldvr,*) :: vr + integer, optional,check(shape(vr, 0) == ldvr),depend(vr) :: ldvr=shape(vr, 0) + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgeev + subroutine dgehrd(n,ilo,ihi,a,lda,tau,work,lwork,info) + integer :: n + integer :: ilo + integer :: ihi + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgehrd + subroutine dorghr(n,ilo,ihi,a,lda,tau,work,lwork,info) + integer :: n + integer :: ilo + integer :: ihi + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dorghr + subroutine dtrexc(compq,n,t,ldt,q,ldq,ifst,ilst,work,info) + character :: compq + integer :: n + double precision dimension(ldt,*) :: t + integer, optional,check(shape(t, 0) == ldt),depend(t) :: ldt=shape(t, 0) + double precision dimension(ldq,*) :: q + integer, optional,check(shape(q, 0) == ldq),depend(q) :: ldq=shape(q, 0) + integer :: ifst + integer :: ilst + double precision dimension(*) :: work + integer :: info + end subroutine dtrexc + subroutine dtrsen(job,compq,select,n,t,ldt,q,ldq,wr,wi,m,s,sep,work,lwork,iwork,liwork,info) + character :: job + character :: compq + logical dimension(*) :: select + integer :: n + double precision dimension(ldt,*) :: t + integer, optional,check(shape(t, 0) == ldt),depend(t) :: ldt=shape(t, 0) + double precision dimension(ldq,*) :: q + integer, optional,check(shape(q, 0) == ldq),depend(q) :: ldq=shape(q, 0) + double precision dimension(*) :: wr + double precision dimension(*) :: wi + integer :: m + double precision :: s + double precision :: sep + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dtrsen + subroutine dtrsyl(trana,tranb,isgn,m,n,a,lda,b,ldb,c,ldc,scale,info) + character :: trana + character :: tranb + integer :: isgn + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + double precision :: scale + integer :: info + end subroutine dtrsyl + subroutine dpteqr(compz,n,d,e,z,ldz,work,info) + character :: compz + integer :: n + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer :: info + end subroutine dpteqr + subroutine dsbev(jobz,uplo,n,kd,ab,ldab,w,z,ldz,work,info) + character :: jobz + character :: uplo + integer :: n + integer :: kd + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + double precision dimension(*) :: w + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer :: info + end subroutine dsbev + subroutine dsbevd(jobz,uplo,n,kd,ab,ldab,w,z,ldz,work,lwork,iwork,liwork,info) + character :: jobz + character :: uplo + integer :: n + integer :: kd + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + double precision dimension(*) :: w + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dsbevd + subroutine dsbevx(jobz,range,uplo,n,kd,ab,ldab,q,ldq,vl,vu,il,iu,abstol,m,w,z,ldz,work,iwork,ifail,info) + character :: jobz + character :: range + character :: uplo + integer :: n + integer :: kd + double precision dimension(ldab,*) :: ab + integer, optional,check(shape(ab, 0) == ldab),depend(ab) :: ldab=shape(ab, 0) + double precision dimension(ldq,*) :: q + integer, optional,check(shape(q, 0) == ldq),depend(q) :: ldq=shape(q, 0) + double precision :: vl + double precision :: vu + integer :: il + integer :: iu + double precision :: abstol + integer :: m + double precision dimension(*) :: w + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer dimension(*) :: ifail + integer :: info + end subroutine dsbevx + subroutine dstebz(range,order,n,vl,vu,il,iu,abstol,d,e,m,nsplit,w,iblock,isplit,work,iwork,info) + character :: range + character :: order + integer :: n + double precision :: vl + double precision :: vu + integer :: il + integer :: iu + double precision :: abstol + double precision dimension(*) :: d + double precision dimension(*) :: e + integer :: m + integer :: nsplit + double precision dimension(*) :: w + integer dimension(*) :: iblock + integer dimension(*) :: isplit + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer :: info + end subroutine dstebz + subroutine dstein(n,d,e,m,w,iblock,isplit,z,ldz,work,iwork,ifail,info) + integer :: n + double precision dimension(*) :: d + double precision dimension(*) :: e + integer :: m + double precision dimension(*) :: w + integer dimension(*) :: iblock + integer dimension(*) :: isplit + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer dimension(*) :: iwork + integer dimension(*) :: ifail + integer :: info + end subroutine dstein + subroutine dstemr(jobz,range,n,d,e,vl,vu,il,iu,m,w,z,ldz,nzc,isuppz,tryrac,work,lwork,iwork,liwork,info) + character :: jobz + character :: range + integer :: n + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision :: vl + double precision :: vu + integer :: il + integer :: iu + integer :: m + double precision dimension(*) :: w + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + integer :: nzc + integer dimension(*) :: isuppz + logical :: tryrac + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dstemr + subroutine dsterf(n,d,e,info) + integer :: n + double precision dimension(*) :: d + double precision dimension(*) :: e + integer :: info + end subroutine dsterf + subroutine dstev(jobz,n,d,e,z,ldz,work,info) + character :: jobz + integer :: n + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer :: info + end subroutine dstev + subroutine dstevd(jobz,n,d,e,z,ldz,work,lwork,iwork,liwork,info) + character :: jobz + integer :: n + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dstevd + subroutine dsyev(jobz,uplo,n,a,lda,w,work,lwork,info) + character :: jobz + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: w + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dsyev + subroutine dsyevd(jobz,uplo,n,a,lda,w,work,lwork,iwork,liwork,info) + character :: jobz + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: w + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dsyevd + subroutine dsyevr(jobz,range,uplo,n,a,lda,vl,vu,il,iu,abstol,m,w,z,ldz,isuppz,work,lwork,iwork,liwork,info) + character :: jobz + character :: range + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision :: vl + double precision :: vu + integer :: il + integer :: iu + double precision :: abstol + integer :: m + double precision dimension(*) :: w + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + integer dimension(*) :: isuppz + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dsyevr + subroutine dsyevx(jobz,range,uplo,n,a,lda,vl,vu,il,iu,abstol,m,w,z,ldz,work,lwork,iwork,ifail,info) + character :: jobz + character :: range + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision :: vl + double precision :: vu + integer :: il + integer :: iu + double precision :: abstol + integer :: m + double precision dimension(*) :: w + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer dimension(*) :: ifail + integer :: info + end subroutine dsyevx + subroutine dsytrd(uplo,n,a,lda,d,e,tau,work,lwork,info) + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: d + double precision dimension(*) :: e + double precision dimension(*) :: tau + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dsytrd + subroutine dggev(jobvl,jobvr,n,a,lda,b,ldb,alphar,alphai,beta,vl,ldvl,vr,ldvr,work,lwork,info) + character :: jobvl + character :: jobvr + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: alphar + double precision dimension(*) :: alphai + double precision dimension(*) :: beta + double precision dimension(ldvl,*) :: vl + integer, optional,check(shape(vl, 0) == ldvl),depend(vl) :: ldvl=shape(vl, 0) + double precision dimension(ldvr,*) :: vr + integer, optional,check(shape(vr, 0) == ldvr),depend(vr) :: ldvr=shape(vr, 0) + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dggev + subroutine dsygst(itype,uplo,n,a,lda,b,ldb,info) + integer :: itype + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + integer :: info + end subroutine dsygst + subroutine dsygv(itype,jobz,uplo,n,a,lda,b,ldb,w,work,lwork,info) + integer :: itype + character :: jobz + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: w + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dsygv + subroutine dsygvd(itype,jobz,uplo,n,a,lda,b,ldb,w,work,lwork,iwork,liwork,info) + integer :: itype + character :: jobz + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: w + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dsygvd + subroutine dsygvx(itype,jobz,range,uplo,n,a,lda,b,ldb,vl,vu,il,iu,abstol,m,w,z,ldz,work,lwork,iwork,ifail,info) + integer :: itype + character :: jobz + character :: range + character :: uplo + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision :: vl + double precision :: vu + integer :: il + integer :: iu + double precision :: abstol + integer :: m + double precision dimension(*) :: w + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer dimension(*) :: ifail + integer :: info + end subroutine dsygvx + subroutine dtgexc(wantq,wantz,n,a,lda,b,ldb,q,ldq,z,ldz,ifst,ilst,work,lwork,info) + logical :: wantq + logical :: wantz + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldq,*) :: q + integer, optional,check(shape(q, 0) == ldq),depend(q) :: ldq=shape(q, 0) + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + integer :: ifst + integer :: ilst + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dtgexc + subroutine dtgsen(ijob,wantq,wantz,select,n,a,lda,b,ldb,alphar,alphai,beta,q,ldq,z,ldz,m,pl,pr,dif,work,lwork,iwork,liwork,info) + integer :: ijob + logical :: wantq + logical :: wantz + logical dimension(*) :: select + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(*) :: alphar + double precision dimension(*) :: alphai + double precision dimension(*) :: beta + double precision dimension(ldq,*) :: q + integer, optional,check(shape(q, 0) == ldq),depend(q) :: ldq=shape(q, 0) + double precision dimension(ldz,*) :: z + integer, optional,check(shape(z, 0) == ldz),depend(z) :: ldz=shape(z, 0) + integer :: m + double precision :: pl + double precision :: pr + double precision dimension(*) :: dif + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: liwork + integer :: info + end subroutine dtgsen + subroutine dtgsyl(trans,ijob,m,n,a,lda,b,ldb,c,ldc,d,ldd,e,lde,f,ldf,scale,dif,work,lwork,iwork,info) + character :: trans + integer :: ijob + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(ldb,*) :: b + integer, optional,check(shape(b, 0) == ldb),depend(b) :: ldb=shape(b, 0) + double precision dimension(ldc,*) :: c + integer, optional,check(shape(c, 0) == ldc),depend(c) :: ldc=shape(c, 0) + double precision dimension(ldd,*) :: d + integer, optional,check(shape(d, 0) == ldd),depend(d) :: ldd=shape(d, 0) + double precision dimension(lde,*) :: e + integer, optional,check(shape(e, 0) == lde),depend(e) :: lde=shape(e, 0) + double precision dimension(ldf,*) :: f + integer, optional,check(shape(f, 0) == ldf),depend(f) :: ldf=shape(f, 0) + double precision :: scale + double precision :: dif + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: info + end subroutine dtgsyl + subroutine dgejsv(joba,jobu,jobv,jobr,jobt,jobp,m,n,a,lda,sva,u,ldu,v,ldv,work,lwork,iwork,info) + character*1 :: joba + character*1 :: jobu + character*1 :: jobv + character*1 :: jobr + character*1 :: jobt + character*1 :: jobp + integer :: m + integer, optional,check(shape(sva, 0) == n),depend(sva) :: n=shape(sva, 0) + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(n) :: sva + double precision dimension(ldu,*) :: u + integer, optional,check(shape(u, 0) == ldu),depend(u) :: ldu=shape(u, 0) + double precision dimension(ldv,*) :: v + integer, optional,check(shape(v, 0) == ldv),depend(v) :: ldv=shape(v, 0) + double precision dimension(lwork) :: work + integer, optional,check(shape(work, 0) == lwork),depend(work) :: lwork=shape(work, 0) + integer dimension(*) :: iwork + integer :: info + end subroutine dgejsv + subroutine dgesdd(jobz,m,n,a,lda,s,u,ldu,vt,ldvt,work,lwork,iwork,info) + character :: jobz + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: s + double precision dimension(ldu,*) :: u + integer, optional,check(shape(u, 0) == ldu),depend(u) :: ldu=shape(u, 0) + double precision dimension(ldvt,*) :: vt + integer, optional,check(shape(vt, 0) == ldvt),depend(vt) :: ldvt=shape(vt, 0) + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: info + end subroutine dgesdd + subroutine dgesvd(jobu,jobvt,m,n,a,lda,s,u,ldu,vt,ldvt,work,lwork,info) + character :: jobu + character :: jobvt + integer :: m + integer :: n + double precision dimension(lda,*) :: a + integer, optional,check(shape(a, 0) == lda),depend(a) :: lda=shape(a, 0) + double precision dimension(*) :: s + double precision dimension(ldu,*) :: u + integer, optional,check(shape(u, 0) == ldu),depend(u) :: ldu=shape(u, 0) + double precision dimension(ldvt,*) :: vt + integer, optional,check(shape(vt, 0) == ldvt),depend(vt) :: ldvt=shape(vt, 0) + double precision dimension(*) :: work + integer :: lwork + integer :: info + end subroutine dgesvd + subroutine dorcsd(jobu1,jobu2,jobv1t,jobv2t,trans,signs,m,p,q,x11,ldx11,x12,ldx12,x21,ldx21,x22,ldx22,theta,u1,ldu1,u2,ldu2,v1t,ldv1t,v2t,ldv2t,work,lwork,iwork,info) + character :: jobu1 + character :: jobu2 + character :: jobv1t + character :: jobv2t + character :: trans + character :: signs + integer :: m + integer :: p + integer :: q + double precision dimension(ldx11,*) :: x11 + integer, optional,check(shape(x11, 0) == ldx11),depend(x11) :: ldx11=shape(x11, 0) + double precision dimension(ldx12,*) :: x12 + integer, optional,check(shape(x12, 0) == ldx12),depend(x12) :: ldx12=shape(x12, 0) + double precision dimension(ldx21,*) :: x21 + integer, optional,check(shape(x21, 0) == ldx21),depend(x21) :: ldx21=shape(x21, 0) + double precision dimension(ldx22,*) :: x22 + integer, optional,check(shape(x22, 0) == ldx22),depend(x22) :: ldx22=shape(x22, 0) + double precision dimension(*) :: theta + double precision dimension(ldu1,*) :: u1 + integer, optional,check(shape(u1, 0) == ldu1),depend(u1) :: ldu1=shape(u1, 0) + double precision dimension(ldu2,*) :: u2 + integer, optional,check(shape(u2, 0) == ldu2),depend(u2) :: ldu2=shape(u2, 0) + double precision dimension(ldv1t,*) :: v1t + integer, optional,check(shape(v1t, 0) == ldv1t),depend(v1t) :: ldv1t=shape(v1t, 0) + double precision dimension(ldv2t,*) :: v2t + integer, optional,check(shape(v2t, 0) == ldv2t),depend(v2t) :: ldv2t=shape(v2t, 0) + double precision dimension(*) :: work + integer :: lwork + integer dimension(*) :: iwork + integer :: info + end subroutine dorcsd + subroutine dlasd4(n,i,d,z,delta,rho,sigma,work,info) + integer :: n + integer :: i + double precision dimension(*) :: d + double precision dimension(*) :: z + double precision dimension(*) :: delta + double precision :: rho + double precision :: sigma + double precision dimension(*) :: work + integer :: info + end subroutine dlasd4 + end interface +end python module f2py_reference_lapack_example + +! This file was auto-generated with f2py (version:2.5.1). +! See: +! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cbbcsd.f b/examples/lapack/native/cbbcsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cbbcsd.f rename to examples/lapack/native/cbbcsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cbdsqr.f b/examples/lapack/native/cbdsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cbdsqr.f rename to examples/lapack/native/cbdsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbbrd.f b/examples/lapack/native/cgbbrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbbrd.f rename to examples/lapack/native/cgbbrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbcon.f b/examples/lapack/native/cgbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbcon.f rename to examples/lapack/native/cgbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbequ.f b/examples/lapack/native/cgbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbequ.f rename to examples/lapack/native/cgbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbequb.f b/examples/lapack/native/cgbequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbequb.f rename to examples/lapack/native/cgbequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbrfs.f b/examples/lapack/native/cgbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbrfs.f rename to examples/lapack/native/cgbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbrfsx.f b/examples/lapack/native/cgbrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbrfsx.f rename to examples/lapack/native/cgbrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbsv.f b/examples/lapack/native/cgbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbsv.f rename to examples/lapack/native/cgbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbsvx.f b/examples/lapack/native/cgbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbsvx.f rename to examples/lapack/native/cgbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbsvxx.f b/examples/lapack/native/cgbsvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbsvxx.f rename to examples/lapack/native/cgbsvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbtf2.f b/examples/lapack/native/cgbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbtf2.f rename to examples/lapack/native/cgbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbtrf.f b/examples/lapack/native/cgbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbtrf.f rename to examples/lapack/native/cgbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbtrs.f b/examples/lapack/native/cgbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgbtrs.f rename to examples/lapack/native/cgbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebak.f b/examples/lapack/native/cgebak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebak.f rename to examples/lapack/native/cgebak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebal.f b/examples/lapack/native/cgebal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebal.f rename to examples/lapack/native/cgebal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebd2.f b/examples/lapack/native/cgebd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebd2.f rename to examples/lapack/native/cgebd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebrd.f b/examples/lapack/native/cgebrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgebrd.f rename to examples/lapack/native/cgebrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgecon.f b/examples/lapack/native/cgecon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgecon.f rename to examples/lapack/native/cgecon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgedmd.f90 b/examples/lapack/native/cgedmd.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgedmd.f90 rename to examples/lapack/native/cgedmd.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgedmdq.f90 b/examples/lapack/native/cgedmdq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgedmdq.f90 rename to examples/lapack/native/cgedmdq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeequ.f b/examples/lapack/native/cgeequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeequ.f rename to examples/lapack/native/cgeequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeequb.f b/examples/lapack/native/cgeequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeequb.f rename to examples/lapack/native/cgeequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgees.f b/examples/lapack/native/cgees.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgees.f rename to examples/lapack/native/cgees.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeesx.f b/examples/lapack/native/cgeesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeesx.f rename to examples/lapack/native/cgeesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeev.f b/examples/lapack/native/cgeev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeev.f rename to examples/lapack/native/cgeev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeevx.f b/examples/lapack/native/cgeevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeevx.f rename to examples/lapack/native/cgeevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgehd2.f b/examples/lapack/native/cgehd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgehd2.f rename to examples/lapack/native/cgehd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgehrd.f b/examples/lapack/native/cgehrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgehrd.f rename to examples/lapack/native/cgehrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgejsv.f b/examples/lapack/native/cgejsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgejsv.f rename to examples/lapack/native/cgejsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelq.f b/examples/lapack/native/cgelq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelq.f rename to examples/lapack/native/cgelq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelq2.f b/examples/lapack/native/cgelq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelq2.f rename to examples/lapack/native/cgelq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelqf.f b/examples/lapack/native/cgelqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelqf.f rename to examples/lapack/native/cgelqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelqt.f b/examples/lapack/native/cgelqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelqt.f rename to examples/lapack/native/cgelqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelqt3.f b/examples/lapack/native/cgelqt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelqt3.f rename to examples/lapack/native/cgelqt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgels.f b/examples/lapack/native/cgels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgels.f rename to examples/lapack/native/cgels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelsd.f b/examples/lapack/native/cgelsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelsd.f rename to examples/lapack/native/cgelsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelss.f b/examples/lapack/native/cgelss.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelss.f rename to examples/lapack/native/cgelss.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelst.f b/examples/lapack/native/cgelst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelst.f rename to examples/lapack/native/cgelst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelsy.f b/examples/lapack/native/cgelsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgelsy.f rename to examples/lapack/native/cgelsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemlq.f b/examples/lapack/native/cgemlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemlq.f rename to examples/lapack/native/cgemlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemlqt.f b/examples/lapack/native/cgemlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemlqt.f rename to examples/lapack/native/cgemlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemqr.f b/examples/lapack/native/cgemqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemqr.f rename to examples/lapack/native/cgemqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemqrt.f b/examples/lapack/native/cgemqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgemqrt.f rename to examples/lapack/native/cgemqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeql2.f b/examples/lapack/native/cgeql2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeql2.f rename to examples/lapack/native/cgeql2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqlf.f b/examples/lapack/native/cgeqlf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqlf.f rename to examples/lapack/native/cgeqlf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqp3.f b/examples/lapack/native/cgeqp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqp3.f rename to examples/lapack/native/cgeqp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqp3rk.f b/examples/lapack/native/cgeqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqp3rk.f rename to examples/lapack/native/cgeqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqr.f b/examples/lapack/native/cgeqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqr.f rename to examples/lapack/native/cgeqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqr2.f b/examples/lapack/native/cgeqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqr2.f rename to examples/lapack/native/cgeqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqr2p.f b/examples/lapack/native/cgeqr2p.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqr2p.f rename to examples/lapack/native/cgeqr2p.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrf.f b/examples/lapack/native/cgeqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrf.f rename to examples/lapack/native/cgeqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrfp.f b/examples/lapack/native/cgeqrfp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrfp.f rename to examples/lapack/native/cgeqrfp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrt.f b/examples/lapack/native/cgeqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrt.f rename to examples/lapack/native/cgeqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrt2.f b/examples/lapack/native/cgeqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrt2.f rename to examples/lapack/native/cgeqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrt3.f b/examples/lapack/native/cgeqrt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgeqrt3.f rename to examples/lapack/native/cgeqrt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerfs.f b/examples/lapack/native/cgerfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerfs.f rename to examples/lapack/native/cgerfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerfsx.f b/examples/lapack/native/cgerfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerfsx.f rename to examples/lapack/native/cgerfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerq2.f b/examples/lapack/native/cgerq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerq2.f rename to examples/lapack/native/cgerq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerqf.f b/examples/lapack/native/cgerqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgerqf.f rename to examples/lapack/native/cgerqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesc2.f b/examples/lapack/native/cgesc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesc2.f rename to examples/lapack/native/cgesc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesdd.f b/examples/lapack/native/cgesdd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesdd.f rename to examples/lapack/native/cgesdd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesv.f b/examples/lapack/native/cgesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesv.f rename to examples/lapack/native/cgesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvd.f b/examples/lapack/native/cgesvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvd.f rename to examples/lapack/native/cgesvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvdq.f b/examples/lapack/native/cgesvdq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvdq.f rename to examples/lapack/native/cgesvdq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvdx.f b/examples/lapack/native/cgesvdx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvdx.f rename to examples/lapack/native/cgesvdx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvj.f b/examples/lapack/native/cgesvj.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvj.f rename to examples/lapack/native/cgesvj.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvx.f b/examples/lapack/native/cgesvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvx.f rename to examples/lapack/native/cgesvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvxx.f b/examples/lapack/native/cgesvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgesvxx.f rename to examples/lapack/native/cgesvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetc2.f b/examples/lapack/native/cgetc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetc2.f rename to examples/lapack/native/cgetc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetf2.f b/examples/lapack/native/cgetf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetf2.f rename to examples/lapack/native/cgetf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetrf.f b/examples/lapack/native/cgetrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetrf.f rename to examples/lapack/native/cgetrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetrf2.f b/examples/lapack/native/cgetrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetrf2.f rename to examples/lapack/native/cgetrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetri.f b/examples/lapack/native/cgetri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetri.f rename to examples/lapack/native/cgetri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetrs.f b/examples/lapack/native/cgetrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetrs.f rename to examples/lapack/native/cgetrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetsls.f b/examples/lapack/native/cgetsls.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetsls.f rename to examples/lapack/native/cgetsls.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetsqrhrt.f b/examples/lapack/native/cgetsqrhrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgetsqrhrt.f rename to examples/lapack/native/cgetsqrhrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggbak.f b/examples/lapack/native/cggbak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggbak.f rename to examples/lapack/native/cggbak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggbal.f b/examples/lapack/native/cggbal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggbal.f rename to examples/lapack/native/cggbal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgges.f b/examples/lapack/native/cgges.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgges.f rename to examples/lapack/native/cgges.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgges3.f b/examples/lapack/native/cgges3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgges3.f rename to examples/lapack/native/cgges3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggesx.f b/examples/lapack/native/cggesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggesx.f rename to examples/lapack/native/cggesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggev.f b/examples/lapack/native/cggev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggev.f rename to examples/lapack/native/cggev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggev3.f b/examples/lapack/native/cggev3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggev3.f rename to examples/lapack/native/cggev3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggevx.f b/examples/lapack/native/cggevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggevx.f rename to examples/lapack/native/cggevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggglm.f b/examples/lapack/native/cggglm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggglm.f rename to examples/lapack/native/cggglm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgghd3.f b/examples/lapack/native/cgghd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgghd3.f rename to examples/lapack/native/cgghd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgghrd.f b/examples/lapack/native/cgghrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgghrd.f rename to examples/lapack/native/cgghrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgglse.f b/examples/lapack/native/cgglse.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgglse.f rename to examples/lapack/native/cgglse.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggqrf.f b/examples/lapack/native/cggqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggqrf.f rename to examples/lapack/native/cggqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggrqf.f b/examples/lapack/native/cggrqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggrqf.f rename to examples/lapack/native/cggrqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggsvd3.f b/examples/lapack/native/cggsvd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggsvd3.f rename to examples/lapack/native/cggsvd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggsvp3.f b/examples/lapack/native/cggsvp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cggsvp3.f rename to examples/lapack/native/cggsvp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgsvj0.f b/examples/lapack/native/cgsvj0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgsvj0.f rename to examples/lapack/native/cgsvj0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgsvj1.f b/examples/lapack/native/cgsvj1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgsvj1.f rename to examples/lapack/native/cgsvj1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtcon.f b/examples/lapack/native/cgtcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtcon.f rename to examples/lapack/native/cgtcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtrfs.f b/examples/lapack/native/cgtrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtrfs.f rename to examples/lapack/native/cgtrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtsv.f b/examples/lapack/native/cgtsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtsv.f rename to examples/lapack/native/cgtsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtsvx.f b/examples/lapack/native/cgtsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtsvx.f rename to examples/lapack/native/cgtsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgttrf.f b/examples/lapack/native/cgttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgttrf.f rename to examples/lapack/native/cgttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgttrs.f b/examples/lapack/native/cgttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgttrs.f rename to examples/lapack/native/cgttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtts2.f b/examples/lapack/native/cgtts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cgtts2.f rename to examples/lapack/native/cgtts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chb2st_kernels.f b/examples/lapack/native/chb2st_kernels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chb2st_kernels.f rename to examples/lapack/native/chb2st_kernels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbev.f b/examples/lapack/native/chbev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbev.f rename to examples/lapack/native/chbev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbev_2stage.f b/examples/lapack/native/chbev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbev_2stage.f rename to examples/lapack/native/chbev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevd.f b/examples/lapack/native/chbevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevd.f rename to examples/lapack/native/chbevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevd_2stage.f b/examples/lapack/native/chbevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevd_2stage.f rename to examples/lapack/native/chbevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevx.f b/examples/lapack/native/chbevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevx.f rename to examples/lapack/native/chbevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevx_2stage.f b/examples/lapack/native/chbevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbevx_2stage.f rename to examples/lapack/native/chbevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgst.f b/examples/lapack/native/chbgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgst.f rename to examples/lapack/native/chbgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgv.f b/examples/lapack/native/chbgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgv.f rename to examples/lapack/native/chbgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgvd.f b/examples/lapack/native/chbgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgvd.f rename to examples/lapack/native/chbgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgvx.f b/examples/lapack/native/chbgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbgvx.f rename to examples/lapack/native/chbgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbtrd.f b/examples/lapack/native/chbtrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chbtrd.f rename to examples/lapack/native/chbtrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/checon.f b/examples/lapack/native/checon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/checon.f rename to examples/lapack/native/checon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/checon_3.f b/examples/lapack/native/checon_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/checon_3.f rename to examples/lapack/native/checon_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/checon_rook.f b/examples/lapack/native/checon_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/checon_rook.f rename to examples/lapack/native/checon_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheequb.f b/examples/lapack/native/cheequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheequb.f rename to examples/lapack/native/cheequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheev.f b/examples/lapack/native/cheev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheev.f rename to examples/lapack/native/cheev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheev_2stage.f b/examples/lapack/native/cheev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheev_2stage.f rename to examples/lapack/native/cheev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevd.f b/examples/lapack/native/cheevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevd.f rename to examples/lapack/native/cheevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevd_2stage.f b/examples/lapack/native/cheevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevd_2stage.f rename to examples/lapack/native/cheevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevr.f b/examples/lapack/native/cheevr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevr.f rename to examples/lapack/native/cheevr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevr_2stage.f b/examples/lapack/native/cheevr_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevr_2stage.f rename to examples/lapack/native/cheevr_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevx.f b/examples/lapack/native/cheevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevx.f rename to examples/lapack/native/cheevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevx_2stage.f b/examples/lapack/native/cheevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheevx_2stage.f rename to examples/lapack/native/cheevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegs2.f b/examples/lapack/native/chegs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegs2.f rename to examples/lapack/native/chegs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegst.f b/examples/lapack/native/chegst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegst.f rename to examples/lapack/native/chegst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegv.f b/examples/lapack/native/chegv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegv.f rename to examples/lapack/native/chegv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegv_2stage.f b/examples/lapack/native/chegv_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegv_2stage.f rename to examples/lapack/native/chegv_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegvd.f b/examples/lapack/native/chegvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegvd.f rename to examples/lapack/native/chegvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegvx.f b/examples/lapack/native/chegvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chegvx.f rename to examples/lapack/native/chegvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cherfs.f b/examples/lapack/native/cherfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cherfs.f rename to examples/lapack/native/cherfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cherfsx.f b/examples/lapack/native/cherfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cherfsx.f rename to examples/lapack/native/cherfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv.f b/examples/lapack/native/chesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv.f rename to examples/lapack/native/chesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_aa.f b/examples/lapack/native/chesv_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_aa.f rename to examples/lapack/native/chesv_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_aa_2stage.f b/examples/lapack/native/chesv_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_aa_2stage.f rename to examples/lapack/native/chesv_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_rk.f b/examples/lapack/native/chesv_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_rk.f rename to examples/lapack/native/chesv_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_rook.f b/examples/lapack/native/chesv_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesv_rook.f rename to examples/lapack/native/chesv_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesvx.f b/examples/lapack/native/chesvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesvx.f rename to examples/lapack/native/chesvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesvxx.f b/examples/lapack/native/chesvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chesvxx.f rename to examples/lapack/native/chesvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheswapr.f b/examples/lapack/native/cheswapr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cheswapr.f rename to examples/lapack/native/cheswapr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetd2.f b/examples/lapack/native/chetd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetd2.f rename to examples/lapack/native/chetd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetf2.f b/examples/lapack/native/chetf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetf2.f rename to examples/lapack/native/chetf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetf2_rk.f b/examples/lapack/native/chetf2_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetf2_rk.f rename to examples/lapack/native/chetf2_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetf2_rook.f b/examples/lapack/native/chetf2_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetf2_rook.f rename to examples/lapack/native/chetf2_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd.f b/examples/lapack/native/chetrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd.f rename to examples/lapack/native/chetrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd_2stage.f b/examples/lapack/native/chetrd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd_2stage.f rename to examples/lapack/native/chetrd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd_hb2st.F b/examples/lapack/native/chetrd_hb2st.F similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd_hb2st.F rename to examples/lapack/native/chetrd_hb2st.F diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd_he2hb.f b/examples/lapack/native/chetrd_he2hb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrd_he2hb.f rename to examples/lapack/native/chetrd_he2hb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf.f b/examples/lapack/native/chetrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf.f rename to examples/lapack/native/chetrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_aa.f b/examples/lapack/native/chetrf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_aa.f rename to examples/lapack/native/chetrf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_aa_2stage.f b/examples/lapack/native/chetrf_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_aa_2stage.f rename to examples/lapack/native/chetrf_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_rk.f b/examples/lapack/native/chetrf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_rk.f rename to examples/lapack/native/chetrf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_rook.f b/examples/lapack/native/chetrf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrf_rook.f rename to examples/lapack/native/chetrf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri.f b/examples/lapack/native/chetri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri.f rename to examples/lapack/native/chetri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri2.f b/examples/lapack/native/chetri2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri2.f rename to examples/lapack/native/chetri2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri2x.f b/examples/lapack/native/chetri2x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri2x.f rename to examples/lapack/native/chetri2x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri_3.f b/examples/lapack/native/chetri_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri_3.f rename to examples/lapack/native/chetri_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri_3x.f b/examples/lapack/native/chetri_3x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri_3x.f rename to examples/lapack/native/chetri_3x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri_rook.f b/examples/lapack/native/chetri_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetri_rook.f rename to examples/lapack/native/chetri_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs.f b/examples/lapack/native/chetrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs.f rename to examples/lapack/native/chetrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs2.f b/examples/lapack/native/chetrs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs2.f rename to examples/lapack/native/chetrs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_3.f b/examples/lapack/native/chetrs_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_3.f rename to examples/lapack/native/chetrs_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_aa.f b/examples/lapack/native/chetrs_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_aa.f rename to examples/lapack/native/chetrs_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_aa_2stage.f b/examples/lapack/native/chetrs_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_aa_2stage.f rename to examples/lapack/native/chetrs_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_rook.f b/examples/lapack/native/chetrs_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chetrs_rook.f rename to examples/lapack/native/chetrs_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chfrk.f b/examples/lapack/native/chfrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chfrk.f rename to examples/lapack/native/chfrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chgeqz.f b/examples/lapack/native/chgeqz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chgeqz.f rename to examples/lapack/native/chgeqz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chla_transtype.f b/examples/lapack/native/chla_transtype.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chla_transtype.f rename to examples/lapack/native/chla_transtype.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpcon.f b/examples/lapack/native/chpcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpcon.f rename to examples/lapack/native/chpcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpev.f b/examples/lapack/native/chpev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpev.f rename to examples/lapack/native/chpev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpevd.f b/examples/lapack/native/chpevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpevd.f rename to examples/lapack/native/chpevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpevx.f b/examples/lapack/native/chpevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpevx.f rename to examples/lapack/native/chpevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgst.f b/examples/lapack/native/chpgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgst.f rename to examples/lapack/native/chpgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgv.f b/examples/lapack/native/chpgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgv.f rename to examples/lapack/native/chpgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgvd.f b/examples/lapack/native/chpgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgvd.f rename to examples/lapack/native/chpgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgvx.f b/examples/lapack/native/chpgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpgvx.f rename to examples/lapack/native/chpgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chprfs.f b/examples/lapack/native/chprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chprfs.f rename to examples/lapack/native/chprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpsv.f b/examples/lapack/native/chpsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpsv.f rename to examples/lapack/native/chpsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpsvx.f b/examples/lapack/native/chpsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chpsvx.f rename to examples/lapack/native/chpsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptrd.f b/examples/lapack/native/chptrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptrd.f rename to examples/lapack/native/chptrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptrf.f b/examples/lapack/native/chptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptrf.f rename to examples/lapack/native/chptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptri.f b/examples/lapack/native/chptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptri.f rename to examples/lapack/native/chptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptrs.f b/examples/lapack/native/chptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chptrs.f rename to examples/lapack/native/chptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chsein.f b/examples/lapack/native/chsein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chsein.f rename to examples/lapack/native/chsein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chseqr.f b/examples/lapack/native/chseqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/chseqr.f rename to examples/lapack/native/chseqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbamv.f b/examples/lapack/native/cla_gbamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbamv.f rename to examples/lapack/native/cla_gbamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrcond_c.f b/examples/lapack/native/cla_gbrcond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrcond_c.f rename to examples/lapack/native/cla_gbrcond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrcond_x.f b/examples/lapack/native/cla_gbrcond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrcond_x.f rename to examples/lapack/native/cla_gbrcond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrfsx_extended.f b/examples/lapack/native/cla_gbrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrfsx_extended.f rename to examples/lapack/native/cla_gbrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrpvgrw.f b/examples/lapack/native/cla_gbrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gbrpvgrw.f rename to examples/lapack/native/cla_gbrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_geamv.f b/examples/lapack/native/cla_geamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_geamv.f rename to examples/lapack/native/cla_geamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gercond_c.f b/examples/lapack/native/cla_gercond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gercond_c.f rename to examples/lapack/native/cla_gercond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gercond_x.f b/examples/lapack/native/cla_gercond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gercond_x.f rename to examples/lapack/native/cla_gercond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gerfsx_extended.f b/examples/lapack/native/cla_gerfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gerfsx_extended.f rename to examples/lapack/native/cla_gerfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gerpvgrw.f b/examples/lapack/native/cla_gerpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_gerpvgrw.f rename to examples/lapack/native/cla_gerpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_heamv.f b/examples/lapack/native/cla_heamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_heamv.f rename to examples/lapack/native/cla_heamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_hercond_c.f b/examples/lapack/native/cla_hercond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_hercond_c.f rename to examples/lapack/native/cla_hercond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_hercond_x.f b/examples/lapack/native/cla_hercond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_hercond_x.f rename to examples/lapack/native/cla_hercond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_herfsx_extended.f b/examples/lapack/native/cla_herfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_herfsx_extended.f rename to examples/lapack/native/cla_herfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_herpvgrw.f b/examples/lapack/native/cla_herpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_herpvgrw.f rename to examples/lapack/native/cla_herpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_lin_berr.f b/examples/lapack/native/cla_lin_berr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_lin_berr.f rename to examples/lapack/native/cla_lin_berr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porcond_c.f b/examples/lapack/native/cla_porcond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porcond_c.f rename to examples/lapack/native/cla_porcond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porcond_x.f b/examples/lapack/native/cla_porcond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porcond_x.f rename to examples/lapack/native/cla_porcond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porfsx_extended.f b/examples/lapack/native/cla_porfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porfsx_extended.f rename to examples/lapack/native/cla_porfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porpvgrw.f b/examples/lapack/native/cla_porpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_porpvgrw.f rename to examples/lapack/native/cla_porpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syamv.f b/examples/lapack/native/cla_syamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syamv.f rename to examples/lapack/native/cla_syamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrcond_c.f b/examples/lapack/native/cla_syrcond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrcond_c.f rename to examples/lapack/native/cla_syrcond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrcond_x.f b/examples/lapack/native/cla_syrcond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrcond_x.f rename to examples/lapack/native/cla_syrcond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrfsx_extended.f b/examples/lapack/native/cla_syrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrfsx_extended.f rename to examples/lapack/native/cla_syrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrpvgrw.f b/examples/lapack/native/cla_syrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_syrpvgrw.f rename to examples/lapack/native/cla_syrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_wwaddw.f b/examples/lapack/native/cla_wwaddw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cla_wwaddw.f rename to examples/lapack/native/cla_wwaddw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clabrd.f b/examples/lapack/native/clabrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clabrd.f rename to examples/lapack/native/clabrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacgv.f b/examples/lapack/native/clacgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacgv.f rename to examples/lapack/native/clacgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacn2.f b/examples/lapack/native/clacn2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacn2.f rename to examples/lapack/native/clacn2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacon.f b/examples/lapack/native/clacon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacon.f rename to examples/lapack/native/clacon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacp2.f b/examples/lapack/native/clacp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacp2.f rename to examples/lapack/native/clacp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacpy.f b/examples/lapack/native/clacpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacpy.f rename to examples/lapack/native/clacpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacrm.f b/examples/lapack/native/clacrm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacrm.f rename to examples/lapack/native/clacrm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacrt.f b/examples/lapack/native/clacrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clacrt.f rename to examples/lapack/native/clacrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cladiv.f b/examples/lapack/native/cladiv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cladiv.f rename to examples/lapack/native/cladiv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claed0.f b/examples/lapack/native/claed0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claed0.f rename to examples/lapack/native/claed0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claed7.f b/examples/lapack/native/claed7.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claed7.f rename to examples/lapack/native/claed7.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claed8.f b/examples/lapack/native/claed8.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claed8.f rename to examples/lapack/native/claed8.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claein.f b/examples/lapack/native/claein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claein.f rename to examples/lapack/native/claein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claesy.f b/examples/lapack/native/claesy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claesy.f rename to examples/lapack/native/claesy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claev2.f b/examples/lapack/native/claev2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claev2.f rename to examples/lapack/native/claev2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clag2z.f b/examples/lapack/native/clag2z.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clag2z.f rename to examples/lapack/native/clag2z.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clags2.f b/examples/lapack/native/clags2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clags2.f rename to examples/lapack/native/clags2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clagtm.f b/examples/lapack/native/clagtm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clagtm.f rename to examples/lapack/native/clagtm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef.f b/examples/lapack/native/clahef.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef.f rename to examples/lapack/native/clahef.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef_aa.f b/examples/lapack/native/clahef_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef_aa.f rename to examples/lapack/native/clahef_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef_rk.f b/examples/lapack/native/clahef_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef_rk.f rename to examples/lapack/native/clahef_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef_rook.f b/examples/lapack/native/clahef_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahef_rook.f rename to examples/lapack/native/clahef_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahqr.f b/examples/lapack/native/clahqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahqr.f rename to examples/lapack/native/clahqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahr2.f b/examples/lapack/native/clahr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clahr2.f rename to examples/lapack/native/clahr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claic1.f b/examples/lapack/native/claic1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claic1.f rename to examples/lapack/native/claic1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clals0.f b/examples/lapack/native/clals0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clals0.f rename to examples/lapack/native/clals0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clalsa.f b/examples/lapack/native/clalsa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clalsa.f rename to examples/lapack/native/clalsa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clalsd.f b/examples/lapack/native/clalsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clalsd.f rename to examples/lapack/native/clalsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clamswlq.f b/examples/lapack/native/clamswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clamswlq.f rename to examples/lapack/native/clamswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clamtsqr.f b/examples/lapack/native/clamtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clamtsqr.f rename to examples/lapack/native/clamtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clangb.f b/examples/lapack/native/clangb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clangb.f rename to examples/lapack/native/clangb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clange.f b/examples/lapack/native/clange.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clange.f rename to examples/lapack/native/clange.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clangt.f b/examples/lapack/native/clangt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clangt.f rename to examples/lapack/native/clangt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhb.f b/examples/lapack/native/clanhb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhb.f rename to examples/lapack/native/clanhb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhe.f b/examples/lapack/native/clanhe.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhe.f rename to examples/lapack/native/clanhe.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhf.f b/examples/lapack/native/clanhf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhf.f rename to examples/lapack/native/clanhf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhp.f b/examples/lapack/native/clanhp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhp.f rename to examples/lapack/native/clanhp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhs.f b/examples/lapack/native/clanhs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanhs.f rename to examples/lapack/native/clanhs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanht.f b/examples/lapack/native/clanht.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clanht.f rename to examples/lapack/native/clanht.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clansb.f b/examples/lapack/native/clansb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clansb.f rename to examples/lapack/native/clansb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clansp.f b/examples/lapack/native/clansp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clansp.f rename to examples/lapack/native/clansp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clansy.f b/examples/lapack/native/clansy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clansy.f rename to examples/lapack/native/clansy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clantb.f b/examples/lapack/native/clantb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clantb.f rename to examples/lapack/native/clantb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clantp.f b/examples/lapack/native/clantp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clantp.f rename to examples/lapack/native/clantp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clantr.f b/examples/lapack/native/clantr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clantr.f rename to examples/lapack/native/clantr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clapll.f b/examples/lapack/native/clapll.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clapll.f rename to examples/lapack/native/clapll.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clapmr.f b/examples/lapack/native/clapmr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clapmr.f rename to examples/lapack/native/clapmr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clapmt.f b/examples/lapack/native/clapmt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clapmt.f rename to examples/lapack/native/clapmt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqgb.f b/examples/lapack/native/claqgb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqgb.f rename to examples/lapack/native/claqgb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqge.f b/examples/lapack/native/claqge.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqge.f rename to examples/lapack/native/claqge.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqhb.f b/examples/lapack/native/claqhb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqhb.f rename to examples/lapack/native/claqhb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqhe.f b/examples/lapack/native/claqhe.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqhe.f rename to examples/lapack/native/claqhe.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqhp.f b/examples/lapack/native/claqhp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqhp.f rename to examples/lapack/native/claqhp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqp2.f b/examples/lapack/native/claqp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqp2.f rename to examples/lapack/native/claqp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqp2rk.f b/examples/lapack/native/claqp2rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqp2rk.f rename to examples/lapack/native/claqp2rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqp3rk.f b/examples/lapack/native/claqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqp3rk.f rename to examples/lapack/native/claqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqps.f b/examples/lapack/native/claqps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqps.f rename to examples/lapack/native/claqps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr0.f b/examples/lapack/native/claqr0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr0.f rename to examples/lapack/native/claqr0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr1.f b/examples/lapack/native/claqr1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr1.f rename to examples/lapack/native/claqr1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr2.f b/examples/lapack/native/claqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr2.f rename to examples/lapack/native/claqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr3.f b/examples/lapack/native/claqr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr3.f rename to examples/lapack/native/claqr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr4.f b/examples/lapack/native/claqr4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr4.f rename to examples/lapack/native/claqr4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr5.f b/examples/lapack/native/claqr5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqr5.f rename to examples/lapack/native/claqr5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqsb.f b/examples/lapack/native/claqsb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqsb.f rename to examples/lapack/native/claqsb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqsp.f b/examples/lapack/native/claqsp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqsp.f rename to examples/lapack/native/claqsp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqsy.f b/examples/lapack/native/claqsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqsy.f rename to examples/lapack/native/claqsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz0.f b/examples/lapack/native/claqz0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz0.f rename to examples/lapack/native/claqz0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz1.f b/examples/lapack/native/claqz1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz1.f rename to examples/lapack/native/claqz1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz2.f b/examples/lapack/native/claqz2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz2.f rename to examples/lapack/native/claqz2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz3.f b/examples/lapack/native/claqz3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claqz3.f rename to examples/lapack/native/claqz3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clar1v.f b/examples/lapack/native/clar1v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clar1v.f rename to examples/lapack/native/clar1v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clar2v.f b/examples/lapack/native/clar2v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clar2v.f rename to examples/lapack/native/clar2v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarcm.f b/examples/lapack/native/clarcm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarcm.f rename to examples/lapack/native/clarcm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarf.f b/examples/lapack/native/clarf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarf.f rename to examples/lapack/native/clarf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarf1f.f b/examples/lapack/native/clarf1f.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarf1f.f rename to examples/lapack/native/clarf1f.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarf1l.f b/examples/lapack/native/clarf1l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarf1l.f rename to examples/lapack/native/clarf1l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfb.f b/examples/lapack/native/clarfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfb.f rename to examples/lapack/native/clarfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfb_gett.f b/examples/lapack/native/clarfb_gett.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfb_gett.f rename to examples/lapack/native/clarfb_gett.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfg.f b/examples/lapack/native/clarfg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfg.f rename to examples/lapack/native/clarfg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfgp.f b/examples/lapack/native/clarfgp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfgp.f rename to examples/lapack/native/clarfgp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarft.f b/examples/lapack/native/clarft.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarft.f rename to examples/lapack/native/clarft.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfx.f b/examples/lapack/native/clarfx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfx.f rename to examples/lapack/native/clarfx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfy.f b/examples/lapack/native/clarfy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarfy.f rename to examples/lapack/native/clarfy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clargv.f b/examples/lapack/native/clargv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clargv.f rename to examples/lapack/native/clargv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarnv.f b/examples/lapack/native/clarnv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarnv.f rename to examples/lapack/native/clarnv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarrv.f b/examples/lapack/native/clarrv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarrv.f rename to examples/lapack/native/clarrv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarscl2.f b/examples/lapack/native/clarscl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarscl2.f rename to examples/lapack/native/clarscl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clartg.f90 b/examples/lapack/native/clartg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clartg.f90 rename to examples/lapack/native/clartg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clartv.f b/examples/lapack/native/clartv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clartv.f rename to examples/lapack/native/clartv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarz.f b/examples/lapack/native/clarz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarz.f rename to examples/lapack/native/clarz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarzb.f b/examples/lapack/native/clarzb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarzb.f rename to examples/lapack/native/clarzb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarzt.f b/examples/lapack/native/clarzt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clarzt.f rename to examples/lapack/native/clarzt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clascl.f b/examples/lapack/native/clascl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clascl.f rename to examples/lapack/native/clascl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clascl2.f b/examples/lapack/native/clascl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clascl2.f rename to examples/lapack/native/clascl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claset.f b/examples/lapack/native/claset.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claset.f rename to examples/lapack/native/claset.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasr.f b/examples/lapack/native/clasr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasr.f rename to examples/lapack/native/clasr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/classq.f90 b/examples/lapack/native/classq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/classq.f90 rename to examples/lapack/native/classq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claswlq.f b/examples/lapack/native/claswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claswlq.f rename to examples/lapack/native/claswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claswp.f b/examples/lapack/native/claswp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claswp.f rename to examples/lapack/native/claswp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf.f b/examples/lapack/native/clasyf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf.f rename to examples/lapack/native/clasyf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf_aa.f b/examples/lapack/native/clasyf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf_aa.f rename to examples/lapack/native/clasyf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf_rk.f b/examples/lapack/native/clasyf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf_rk.f rename to examples/lapack/native/clasyf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf_rook.f b/examples/lapack/native/clasyf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clasyf_rook.f rename to examples/lapack/native/clasyf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatbs.f b/examples/lapack/native/clatbs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatbs.f rename to examples/lapack/native/clatbs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatdf.f b/examples/lapack/native/clatdf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatdf.f rename to examples/lapack/native/clatdf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatps.f b/examples/lapack/native/clatps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatps.f rename to examples/lapack/native/clatps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrd.f b/examples/lapack/native/clatrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrd.f rename to examples/lapack/native/clatrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrs.f b/examples/lapack/native/clatrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrs.f rename to examples/lapack/native/clatrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrs3.f b/examples/lapack/native/clatrs3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrs3.f rename to examples/lapack/native/clatrs3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrz.f b/examples/lapack/native/clatrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatrz.f rename to examples/lapack/native/clatrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatsqr.f b/examples/lapack/native/clatsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clatsqr.f rename to examples/lapack/native/clatsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claunhr_col_getrfnp.f b/examples/lapack/native/claunhr_col_getrfnp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claunhr_col_getrfnp.f rename to examples/lapack/native/claunhr_col_getrfnp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claunhr_col_getrfnp2.f b/examples/lapack/native/claunhr_col_getrfnp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/claunhr_col_getrfnp2.f rename to examples/lapack/native/claunhr_col_getrfnp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clauu2.f b/examples/lapack/native/clauu2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clauu2.f rename to examples/lapack/native/clauu2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clauum.f b/examples/lapack/native/clauum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/clauum.f rename to examples/lapack/native/clauum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbcon.f b/examples/lapack/native/cpbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbcon.f rename to examples/lapack/native/cpbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbequ.f b/examples/lapack/native/cpbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbequ.f rename to examples/lapack/native/cpbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbrfs.f b/examples/lapack/native/cpbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbrfs.f rename to examples/lapack/native/cpbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbstf.f b/examples/lapack/native/cpbstf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbstf.f rename to examples/lapack/native/cpbstf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbsv.f b/examples/lapack/native/cpbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbsv.f rename to examples/lapack/native/cpbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbsvx.f b/examples/lapack/native/cpbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbsvx.f rename to examples/lapack/native/cpbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbtf2.f b/examples/lapack/native/cpbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbtf2.f rename to examples/lapack/native/cpbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbtrf.f b/examples/lapack/native/cpbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbtrf.f rename to examples/lapack/native/cpbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbtrs.f b/examples/lapack/native/cpbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpbtrs.f rename to examples/lapack/native/cpbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpftrf.f b/examples/lapack/native/cpftrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpftrf.f rename to examples/lapack/native/cpftrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpftri.f b/examples/lapack/native/cpftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpftri.f rename to examples/lapack/native/cpftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpftrs.f b/examples/lapack/native/cpftrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpftrs.f rename to examples/lapack/native/cpftrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpocon.f b/examples/lapack/native/cpocon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpocon.f rename to examples/lapack/native/cpocon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpoequ.f b/examples/lapack/native/cpoequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpoequ.f rename to examples/lapack/native/cpoequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpoequb.f b/examples/lapack/native/cpoequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpoequb.f rename to examples/lapack/native/cpoequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cporfs.f b/examples/lapack/native/cporfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cporfs.f rename to examples/lapack/native/cporfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cporfsx.f b/examples/lapack/native/cporfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cporfsx.f rename to examples/lapack/native/cporfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cposv.f b/examples/lapack/native/cposv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cposv.f rename to examples/lapack/native/cposv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cposvx.f b/examples/lapack/native/cposvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cposvx.f rename to examples/lapack/native/cposvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cposvxx.f b/examples/lapack/native/cposvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cposvxx.f rename to examples/lapack/native/cposvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotf2.f b/examples/lapack/native/cpotf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotf2.f rename to examples/lapack/native/cpotf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotrf.f b/examples/lapack/native/cpotrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotrf.f rename to examples/lapack/native/cpotrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotrf2.f b/examples/lapack/native/cpotrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotrf2.f rename to examples/lapack/native/cpotrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotri.f b/examples/lapack/native/cpotri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotri.f rename to examples/lapack/native/cpotri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotrs.f b/examples/lapack/native/cpotrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpotrs.f rename to examples/lapack/native/cpotrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppcon.f b/examples/lapack/native/cppcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppcon.f rename to examples/lapack/native/cppcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppequ.f b/examples/lapack/native/cppequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppequ.f rename to examples/lapack/native/cppequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpprfs.f b/examples/lapack/native/cpprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpprfs.f rename to examples/lapack/native/cpprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppsv.f b/examples/lapack/native/cppsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppsv.f rename to examples/lapack/native/cppsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppsvx.f b/examples/lapack/native/cppsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cppsvx.f rename to examples/lapack/native/cppsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpptrf.f b/examples/lapack/native/cpptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpptrf.f rename to examples/lapack/native/cpptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpptri.f b/examples/lapack/native/cpptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpptri.f rename to examples/lapack/native/cpptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpptrs.f b/examples/lapack/native/cpptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpptrs.f rename to examples/lapack/native/cpptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpstf2.f b/examples/lapack/native/cpstf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpstf2.f rename to examples/lapack/native/cpstf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpstrf.f b/examples/lapack/native/cpstrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpstrf.f rename to examples/lapack/native/cpstrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptcon.f b/examples/lapack/native/cptcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptcon.f rename to examples/lapack/native/cptcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpteqr.f b/examples/lapack/native/cpteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpteqr.f rename to examples/lapack/native/cpteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptrfs.f b/examples/lapack/native/cptrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptrfs.f rename to examples/lapack/native/cptrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptsv.f b/examples/lapack/native/cptsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptsv.f rename to examples/lapack/native/cptsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptsvx.f b/examples/lapack/native/cptsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptsvx.f rename to examples/lapack/native/cptsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpttrf.f b/examples/lapack/native/cpttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpttrf.f rename to examples/lapack/native/cpttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpttrs.f b/examples/lapack/native/cpttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cpttrs.f rename to examples/lapack/native/cpttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptts2.f b/examples/lapack/native/cptts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cptts2.f rename to examples/lapack/native/cptts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/crot.f b/examples/lapack/native/crot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/crot.f rename to examples/lapack/native/crot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/crscl.f b/examples/lapack/native/crscl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/crscl.f rename to examples/lapack/native/crscl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspcon.f b/examples/lapack/native/cspcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspcon.f rename to examples/lapack/native/cspcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspmv.f b/examples/lapack/native/cspmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspmv.f rename to examples/lapack/native/cspmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspr.f b/examples/lapack/native/cspr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspr.f rename to examples/lapack/native/cspr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csprfs.f b/examples/lapack/native/csprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csprfs.f rename to examples/lapack/native/csprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspsv.f b/examples/lapack/native/cspsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspsv.f rename to examples/lapack/native/cspsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspsvx.f b/examples/lapack/native/cspsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cspsvx.f rename to examples/lapack/native/cspsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csptrf.f b/examples/lapack/native/csptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csptrf.f rename to examples/lapack/native/csptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csptri.f b/examples/lapack/native/csptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csptri.f rename to examples/lapack/native/csptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csptrs.f b/examples/lapack/native/csptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csptrs.f rename to examples/lapack/native/csptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csrscl.f b/examples/lapack/native/csrscl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csrscl.f rename to examples/lapack/native/csrscl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstedc.f b/examples/lapack/native/cstedc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstedc.f rename to examples/lapack/native/cstedc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstegr.f b/examples/lapack/native/cstegr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstegr.f rename to examples/lapack/native/cstegr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstein.f b/examples/lapack/native/cstein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstein.f rename to examples/lapack/native/cstein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstemr.f b/examples/lapack/native/cstemr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cstemr.f rename to examples/lapack/native/cstemr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csteqr.f b/examples/lapack/native/csteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csteqr.f rename to examples/lapack/native/csteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csycon.f b/examples/lapack/native/csycon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csycon.f rename to examples/lapack/native/csycon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csycon_3.f b/examples/lapack/native/csycon_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csycon_3.f rename to examples/lapack/native/csycon_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csycon_rook.f b/examples/lapack/native/csycon_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csycon_rook.f rename to examples/lapack/native/csycon_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyconv.f b/examples/lapack/native/csyconv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyconv.f rename to examples/lapack/native/csyconv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyconvf.f b/examples/lapack/native/csyconvf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyconvf.f rename to examples/lapack/native/csyconvf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyconvf_rook.f b/examples/lapack/native/csyconvf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyconvf_rook.f rename to examples/lapack/native/csyconvf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyequb.f b/examples/lapack/native/csyequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyequb.f rename to examples/lapack/native/csyequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csymv.f b/examples/lapack/native/csymv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csymv.f rename to examples/lapack/native/csymv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyr.f b/examples/lapack/native/csyr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyr.f rename to examples/lapack/native/csyr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyrfs.f b/examples/lapack/native/csyrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyrfs.f rename to examples/lapack/native/csyrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyrfsx.f b/examples/lapack/native/csyrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyrfsx.f rename to examples/lapack/native/csyrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv.f b/examples/lapack/native/csysv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv.f rename to examples/lapack/native/csysv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_aa.f b/examples/lapack/native/csysv_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_aa.f rename to examples/lapack/native/csysv_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_aa_2stage.f b/examples/lapack/native/csysv_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_aa_2stage.f rename to examples/lapack/native/csysv_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_rk.f b/examples/lapack/native/csysv_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_rk.f rename to examples/lapack/native/csysv_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_rook.f b/examples/lapack/native/csysv_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysv_rook.f rename to examples/lapack/native/csysv_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysvx.f b/examples/lapack/native/csysvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysvx.f rename to examples/lapack/native/csysvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysvxx.f b/examples/lapack/native/csysvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csysvxx.f rename to examples/lapack/native/csysvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyswapr.f b/examples/lapack/native/csyswapr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csyswapr.f rename to examples/lapack/native/csyswapr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytf2.f b/examples/lapack/native/csytf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytf2.f rename to examples/lapack/native/csytf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytf2_rk.f b/examples/lapack/native/csytf2_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytf2_rk.f rename to examples/lapack/native/csytf2_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytf2_rook.f b/examples/lapack/native/csytf2_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytf2_rook.f rename to examples/lapack/native/csytf2_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf.f b/examples/lapack/native/csytrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf.f rename to examples/lapack/native/csytrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_aa.f b/examples/lapack/native/csytrf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_aa.f rename to examples/lapack/native/csytrf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_aa_2stage.f b/examples/lapack/native/csytrf_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_aa_2stage.f rename to examples/lapack/native/csytrf_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_rk.f b/examples/lapack/native/csytrf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_rk.f rename to examples/lapack/native/csytrf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_rook.f b/examples/lapack/native/csytrf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrf_rook.f rename to examples/lapack/native/csytrf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri.f b/examples/lapack/native/csytri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri.f rename to examples/lapack/native/csytri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri2.f b/examples/lapack/native/csytri2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri2.f rename to examples/lapack/native/csytri2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri2x.f b/examples/lapack/native/csytri2x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri2x.f rename to examples/lapack/native/csytri2x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri_3.f b/examples/lapack/native/csytri_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri_3.f rename to examples/lapack/native/csytri_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri_3x.f b/examples/lapack/native/csytri_3x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri_3x.f rename to examples/lapack/native/csytri_3x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri_rook.f b/examples/lapack/native/csytri_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytri_rook.f rename to examples/lapack/native/csytri_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs.f b/examples/lapack/native/csytrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs.f rename to examples/lapack/native/csytrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs2.f b/examples/lapack/native/csytrs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs2.f rename to examples/lapack/native/csytrs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_3.f b/examples/lapack/native/csytrs_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_3.f rename to examples/lapack/native/csytrs_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_aa.f b/examples/lapack/native/csytrs_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_aa.f rename to examples/lapack/native/csytrs_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_aa_2stage.f b/examples/lapack/native/csytrs_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_aa_2stage.f rename to examples/lapack/native/csytrs_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_rook.f b/examples/lapack/native/csytrs_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/csytrs_rook.f rename to examples/lapack/native/csytrs_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctbcon.f b/examples/lapack/native/ctbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctbcon.f rename to examples/lapack/native/ctbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctbrfs.f b/examples/lapack/native/ctbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctbrfs.f rename to examples/lapack/native/ctbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctbtrs.f b/examples/lapack/native/ctbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctbtrs.f rename to examples/lapack/native/ctbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctfsm.f b/examples/lapack/native/ctfsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctfsm.f rename to examples/lapack/native/ctfsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctftri.f b/examples/lapack/native/ctftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctftri.f rename to examples/lapack/native/ctftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctfttp.f b/examples/lapack/native/ctfttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctfttp.f rename to examples/lapack/native/ctfttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctfttr.f b/examples/lapack/native/ctfttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctfttr.f rename to examples/lapack/native/ctfttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgevc.f b/examples/lapack/native/ctgevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgevc.f rename to examples/lapack/native/ctgevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgex2.f b/examples/lapack/native/ctgex2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgex2.f rename to examples/lapack/native/ctgex2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgexc.f b/examples/lapack/native/ctgexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgexc.f rename to examples/lapack/native/ctgexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsen.f b/examples/lapack/native/ctgsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsen.f rename to examples/lapack/native/ctgsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsja.f b/examples/lapack/native/ctgsja.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsja.f rename to examples/lapack/native/ctgsja.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsna.f b/examples/lapack/native/ctgsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsna.f rename to examples/lapack/native/ctgsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsy2.f b/examples/lapack/native/ctgsy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsy2.f rename to examples/lapack/native/ctgsy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsyl.f b/examples/lapack/native/ctgsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctgsyl.f rename to examples/lapack/native/ctgsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpcon.f b/examples/lapack/native/ctpcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpcon.f rename to examples/lapack/native/ctpcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctplqt.f b/examples/lapack/native/ctplqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctplqt.f rename to examples/lapack/native/ctplqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctplqt2.f b/examples/lapack/native/ctplqt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctplqt2.f rename to examples/lapack/native/ctplqt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpmlqt.f b/examples/lapack/native/ctpmlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpmlqt.f rename to examples/lapack/native/ctpmlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpmqrt.f b/examples/lapack/native/ctpmqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpmqrt.f rename to examples/lapack/native/ctpmqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpqrt.f b/examples/lapack/native/ctpqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpqrt.f rename to examples/lapack/native/ctpqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpqrt2.f b/examples/lapack/native/ctpqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpqrt2.f rename to examples/lapack/native/ctpqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctprfb.f b/examples/lapack/native/ctprfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctprfb.f rename to examples/lapack/native/ctprfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctprfs.f b/examples/lapack/native/ctprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctprfs.f rename to examples/lapack/native/ctprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctptri.f b/examples/lapack/native/ctptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctptri.f rename to examples/lapack/native/ctptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctptrs.f b/examples/lapack/native/ctptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctptrs.f rename to examples/lapack/native/ctptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpttf.f b/examples/lapack/native/ctpttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpttf.f rename to examples/lapack/native/ctpttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpttr.f b/examples/lapack/native/ctpttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctpttr.f rename to examples/lapack/native/ctpttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrcon.f b/examples/lapack/native/ctrcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrcon.f rename to examples/lapack/native/ctrcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrevc.f b/examples/lapack/native/ctrevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrevc.f rename to examples/lapack/native/ctrevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrevc3.f b/examples/lapack/native/ctrevc3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrevc3.f rename to examples/lapack/native/ctrevc3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrexc.f b/examples/lapack/native/ctrexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrexc.f rename to examples/lapack/native/ctrexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrrfs.f b/examples/lapack/native/ctrrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrrfs.f rename to examples/lapack/native/ctrrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsen.f b/examples/lapack/native/ctrsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsen.f rename to examples/lapack/native/ctrsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsna.f b/examples/lapack/native/ctrsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsna.f rename to examples/lapack/native/ctrsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsyl.f b/examples/lapack/native/ctrsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsyl.f rename to examples/lapack/native/ctrsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsyl3.f b/examples/lapack/native/ctrsyl3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrsyl3.f rename to examples/lapack/native/ctrsyl3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrti2.f b/examples/lapack/native/ctrti2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrti2.f rename to examples/lapack/native/ctrti2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrtri.f b/examples/lapack/native/ctrtri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrtri.f rename to examples/lapack/native/ctrtri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrtrs.f b/examples/lapack/native/ctrtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrtrs.f rename to examples/lapack/native/ctrtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrttf.f b/examples/lapack/native/ctrttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrttf.f rename to examples/lapack/native/ctrttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrttp.f b/examples/lapack/native/ctrttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctrttp.f rename to examples/lapack/native/ctrttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctzrzf.f b/examples/lapack/native/ctzrzf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ctzrzf.f rename to examples/lapack/native/ctzrzf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb.f b/examples/lapack/native/cunbdb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb.f rename to examples/lapack/native/cunbdb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb1.f b/examples/lapack/native/cunbdb1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb1.f rename to examples/lapack/native/cunbdb1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb2.f b/examples/lapack/native/cunbdb2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb2.f rename to examples/lapack/native/cunbdb2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb3.f b/examples/lapack/native/cunbdb3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb3.f rename to examples/lapack/native/cunbdb3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb4.f b/examples/lapack/native/cunbdb4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb4.f rename to examples/lapack/native/cunbdb4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb5.f b/examples/lapack/native/cunbdb5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb5.f rename to examples/lapack/native/cunbdb5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb6.f b/examples/lapack/native/cunbdb6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunbdb6.f rename to examples/lapack/native/cunbdb6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cuncsd.f b/examples/lapack/native/cuncsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cuncsd.f rename to examples/lapack/native/cuncsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cuncsd2by1.f b/examples/lapack/native/cuncsd2by1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cuncsd2by1.f rename to examples/lapack/native/cuncsd2by1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cung2l.f b/examples/lapack/native/cung2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cung2l.f rename to examples/lapack/native/cung2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cung2r.f b/examples/lapack/native/cung2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cung2r.f rename to examples/lapack/native/cung2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungbr.f b/examples/lapack/native/cungbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungbr.f rename to examples/lapack/native/cungbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunghr.f b/examples/lapack/native/cunghr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunghr.f rename to examples/lapack/native/cunghr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungl2.f b/examples/lapack/native/cungl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungl2.f rename to examples/lapack/native/cungl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunglq.f b/examples/lapack/native/cunglq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunglq.f rename to examples/lapack/native/cunglq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungql.f b/examples/lapack/native/cungql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungql.f rename to examples/lapack/native/cungql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungqr.f b/examples/lapack/native/cungqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungqr.f rename to examples/lapack/native/cungqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungr2.f b/examples/lapack/native/cungr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungr2.f rename to examples/lapack/native/cungr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungrq.f b/examples/lapack/native/cungrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungrq.f rename to examples/lapack/native/cungrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungtr.f b/examples/lapack/native/cungtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungtr.f rename to examples/lapack/native/cungtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungtsqr.f b/examples/lapack/native/cungtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungtsqr.f rename to examples/lapack/native/cungtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungtsqr_row.f b/examples/lapack/native/cungtsqr_row.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cungtsqr_row.f rename to examples/lapack/native/cungtsqr_row.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunhr_col.f b/examples/lapack/native/cunhr_col.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunhr_col.f rename to examples/lapack/native/cunhr_col.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunm22.f b/examples/lapack/native/cunm22.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunm22.f rename to examples/lapack/native/cunm22.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunm2l.f b/examples/lapack/native/cunm2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunm2l.f rename to examples/lapack/native/cunm2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunm2r.f b/examples/lapack/native/cunm2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunm2r.f rename to examples/lapack/native/cunm2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmbr.f b/examples/lapack/native/cunmbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmbr.f rename to examples/lapack/native/cunmbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmhr.f b/examples/lapack/native/cunmhr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmhr.f rename to examples/lapack/native/cunmhr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunml2.f b/examples/lapack/native/cunml2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunml2.f rename to examples/lapack/native/cunml2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmlq.f b/examples/lapack/native/cunmlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmlq.f rename to examples/lapack/native/cunmlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmql.f b/examples/lapack/native/cunmql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmql.f rename to examples/lapack/native/cunmql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmqr.f b/examples/lapack/native/cunmqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmqr.f rename to examples/lapack/native/cunmqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmr2.f b/examples/lapack/native/cunmr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmr2.f rename to examples/lapack/native/cunmr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmr3.f b/examples/lapack/native/cunmr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmr3.f rename to examples/lapack/native/cunmr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmrq.f b/examples/lapack/native/cunmrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmrq.f rename to examples/lapack/native/cunmrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmrz.f b/examples/lapack/native/cunmrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmrz.f rename to examples/lapack/native/cunmrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmtr.f b/examples/lapack/native/cunmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cunmtr.f rename to examples/lapack/native/cunmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cupgtr.f b/examples/lapack/native/cupgtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cupgtr.f rename to examples/lapack/native/cupgtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cupmtr.f b/examples/lapack/native/cupmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/cupmtr.f rename to examples/lapack/native/cupmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbbcsd.f b/examples/lapack/native/dbbcsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbbcsd.f rename to examples/lapack/native/dbbcsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbdsdc.f b/examples/lapack/native/dbdsdc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbdsdc.f rename to examples/lapack/native/dbdsdc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbdsqr.f b/examples/lapack/native/dbdsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbdsqr.f rename to examples/lapack/native/dbdsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbdsvdx.f b/examples/lapack/native/dbdsvdx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dbdsvdx.f rename to examples/lapack/native/dbdsvdx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ddisna.f b/examples/lapack/native/ddisna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ddisna.f rename to examples/lapack/native/ddisna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbbrd.f b/examples/lapack/native/dgbbrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbbrd.f rename to examples/lapack/native/dgbbrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbcon.f b/examples/lapack/native/dgbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbcon.f rename to examples/lapack/native/dgbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbequ.f b/examples/lapack/native/dgbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbequ.f rename to examples/lapack/native/dgbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbequb.f b/examples/lapack/native/dgbequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbequb.f rename to examples/lapack/native/dgbequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbrfs.f b/examples/lapack/native/dgbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbrfs.f rename to examples/lapack/native/dgbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbrfsx.f b/examples/lapack/native/dgbrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbrfsx.f rename to examples/lapack/native/dgbrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbsv.f b/examples/lapack/native/dgbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbsv.f rename to examples/lapack/native/dgbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbsvx.f b/examples/lapack/native/dgbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbsvx.f rename to examples/lapack/native/dgbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbsvxx.f b/examples/lapack/native/dgbsvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbsvxx.f rename to examples/lapack/native/dgbsvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbtf2.f b/examples/lapack/native/dgbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbtf2.f rename to examples/lapack/native/dgbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbtrf.f b/examples/lapack/native/dgbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbtrf.f rename to examples/lapack/native/dgbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbtrs.f b/examples/lapack/native/dgbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgbtrs.f rename to examples/lapack/native/dgbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebak.f b/examples/lapack/native/dgebak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebak.f rename to examples/lapack/native/dgebak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebal.f b/examples/lapack/native/dgebal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebal.f rename to examples/lapack/native/dgebal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebd2.f b/examples/lapack/native/dgebd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebd2.f rename to examples/lapack/native/dgebd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebrd.f b/examples/lapack/native/dgebrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgebrd.f rename to examples/lapack/native/dgebrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgecon.f b/examples/lapack/native/dgecon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgecon.f rename to examples/lapack/native/dgecon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgedmd.f90 b/examples/lapack/native/dgedmd.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgedmd.f90 rename to examples/lapack/native/dgedmd.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgedmdq.f90 b/examples/lapack/native/dgedmdq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgedmdq.f90 rename to examples/lapack/native/dgedmdq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeequ.f b/examples/lapack/native/dgeequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeequ.f rename to examples/lapack/native/dgeequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeequb.f b/examples/lapack/native/dgeequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeequb.f rename to examples/lapack/native/dgeequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgees.f b/examples/lapack/native/dgees.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgees.f rename to examples/lapack/native/dgees.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeesx.f b/examples/lapack/native/dgeesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeesx.f rename to examples/lapack/native/dgeesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeev.f b/examples/lapack/native/dgeev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeev.f rename to examples/lapack/native/dgeev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeevx.f b/examples/lapack/native/dgeevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeevx.f rename to examples/lapack/native/dgeevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgehd2.f b/examples/lapack/native/dgehd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgehd2.f rename to examples/lapack/native/dgehd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgehrd.f b/examples/lapack/native/dgehrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgehrd.f rename to examples/lapack/native/dgehrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgejsv.f b/examples/lapack/native/dgejsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgejsv.f rename to examples/lapack/native/dgejsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelq.f b/examples/lapack/native/dgelq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelq.f rename to examples/lapack/native/dgelq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelq2.f b/examples/lapack/native/dgelq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelq2.f rename to examples/lapack/native/dgelq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelqf.f b/examples/lapack/native/dgelqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelqf.f rename to examples/lapack/native/dgelqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelqt.f b/examples/lapack/native/dgelqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelqt.f rename to examples/lapack/native/dgelqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelqt3.f b/examples/lapack/native/dgelqt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelqt3.f rename to examples/lapack/native/dgelqt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgels.f b/examples/lapack/native/dgels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgels.f rename to examples/lapack/native/dgels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelsd.f b/examples/lapack/native/dgelsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelsd.f rename to examples/lapack/native/dgelsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelss.f b/examples/lapack/native/dgelss.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelss.f rename to examples/lapack/native/dgelss.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelst.f b/examples/lapack/native/dgelst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelst.f rename to examples/lapack/native/dgelst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelsy.f b/examples/lapack/native/dgelsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgelsy.f rename to examples/lapack/native/dgelsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemlq.f b/examples/lapack/native/dgemlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemlq.f rename to examples/lapack/native/dgemlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemlqt.f b/examples/lapack/native/dgemlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemlqt.f rename to examples/lapack/native/dgemlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemqr.f b/examples/lapack/native/dgemqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemqr.f rename to examples/lapack/native/dgemqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemqrt.f b/examples/lapack/native/dgemqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgemqrt.f rename to examples/lapack/native/dgemqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeql2.f b/examples/lapack/native/dgeql2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeql2.f rename to examples/lapack/native/dgeql2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqlf.f b/examples/lapack/native/dgeqlf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqlf.f rename to examples/lapack/native/dgeqlf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqp3.f b/examples/lapack/native/dgeqp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqp3.f rename to examples/lapack/native/dgeqp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqp3rk.f b/examples/lapack/native/dgeqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqp3rk.f rename to examples/lapack/native/dgeqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqr.f b/examples/lapack/native/dgeqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqr.f rename to examples/lapack/native/dgeqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqr2.f b/examples/lapack/native/dgeqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqr2.f rename to examples/lapack/native/dgeqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqr2p.f b/examples/lapack/native/dgeqr2p.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqr2p.f rename to examples/lapack/native/dgeqr2p.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrf.f b/examples/lapack/native/dgeqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrf.f rename to examples/lapack/native/dgeqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrfp.f b/examples/lapack/native/dgeqrfp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrfp.f rename to examples/lapack/native/dgeqrfp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrt.f b/examples/lapack/native/dgeqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrt.f rename to examples/lapack/native/dgeqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrt2.f b/examples/lapack/native/dgeqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrt2.f rename to examples/lapack/native/dgeqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrt3.f b/examples/lapack/native/dgeqrt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgeqrt3.f rename to examples/lapack/native/dgeqrt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerfs.f b/examples/lapack/native/dgerfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerfs.f rename to examples/lapack/native/dgerfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerfsx.f b/examples/lapack/native/dgerfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerfsx.f rename to examples/lapack/native/dgerfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerq2.f b/examples/lapack/native/dgerq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerq2.f rename to examples/lapack/native/dgerq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerqf.f b/examples/lapack/native/dgerqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgerqf.f rename to examples/lapack/native/dgerqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesc2.f b/examples/lapack/native/dgesc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesc2.f rename to examples/lapack/native/dgesc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesdd.f b/examples/lapack/native/dgesdd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesdd.f rename to examples/lapack/native/dgesdd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesv.f b/examples/lapack/native/dgesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesv.f rename to examples/lapack/native/dgesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvd.f b/examples/lapack/native/dgesvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvd.f rename to examples/lapack/native/dgesvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvdq.f b/examples/lapack/native/dgesvdq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvdq.f rename to examples/lapack/native/dgesvdq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvdx.f b/examples/lapack/native/dgesvdx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvdx.f rename to examples/lapack/native/dgesvdx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvj.f b/examples/lapack/native/dgesvj.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvj.f rename to examples/lapack/native/dgesvj.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvx.f b/examples/lapack/native/dgesvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvx.f rename to examples/lapack/native/dgesvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvxx.f b/examples/lapack/native/dgesvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgesvxx.f rename to examples/lapack/native/dgesvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetc2.f b/examples/lapack/native/dgetc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetc2.f rename to examples/lapack/native/dgetc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetf2.f b/examples/lapack/native/dgetf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetf2.f rename to examples/lapack/native/dgetf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetrf.f b/examples/lapack/native/dgetrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetrf.f rename to examples/lapack/native/dgetrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetrf2.f b/examples/lapack/native/dgetrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetrf2.f rename to examples/lapack/native/dgetrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetri.f b/examples/lapack/native/dgetri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetri.f rename to examples/lapack/native/dgetri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetrs.f b/examples/lapack/native/dgetrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetrs.f rename to examples/lapack/native/dgetrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetsls.f b/examples/lapack/native/dgetsls.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetsls.f rename to examples/lapack/native/dgetsls.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetsqrhrt.f b/examples/lapack/native/dgetsqrhrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgetsqrhrt.f rename to examples/lapack/native/dgetsqrhrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggbak.f b/examples/lapack/native/dggbak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggbak.f rename to examples/lapack/native/dggbak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggbal.f b/examples/lapack/native/dggbal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggbal.f rename to examples/lapack/native/dggbal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgges.f b/examples/lapack/native/dgges.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgges.f rename to examples/lapack/native/dgges.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgges3.f b/examples/lapack/native/dgges3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgges3.f rename to examples/lapack/native/dgges3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggesx.f b/examples/lapack/native/dggesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggesx.f rename to examples/lapack/native/dggesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggev.f b/examples/lapack/native/dggev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggev.f rename to examples/lapack/native/dggev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggev3.f b/examples/lapack/native/dggev3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggev3.f rename to examples/lapack/native/dggev3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggevx.f b/examples/lapack/native/dggevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggevx.f rename to examples/lapack/native/dggevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggglm.f b/examples/lapack/native/dggglm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggglm.f rename to examples/lapack/native/dggglm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgghd3.f b/examples/lapack/native/dgghd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgghd3.f rename to examples/lapack/native/dgghd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgghrd.f b/examples/lapack/native/dgghrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgghrd.f rename to examples/lapack/native/dgghrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgglse.f b/examples/lapack/native/dgglse.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgglse.f rename to examples/lapack/native/dgglse.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggqrf.f b/examples/lapack/native/dggqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggqrf.f rename to examples/lapack/native/dggqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggrqf.f b/examples/lapack/native/dggrqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggrqf.f rename to examples/lapack/native/dggrqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggsvd3.f b/examples/lapack/native/dggsvd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggsvd3.f rename to examples/lapack/native/dggsvd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggsvp3.f b/examples/lapack/native/dggsvp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dggsvp3.f rename to examples/lapack/native/dggsvp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgsvj0.f b/examples/lapack/native/dgsvj0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgsvj0.f rename to examples/lapack/native/dgsvj0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgsvj1.f b/examples/lapack/native/dgsvj1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgsvj1.f rename to examples/lapack/native/dgsvj1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtcon.f b/examples/lapack/native/dgtcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtcon.f rename to examples/lapack/native/dgtcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtrfs.f b/examples/lapack/native/dgtrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtrfs.f rename to examples/lapack/native/dgtrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtsv.f b/examples/lapack/native/dgtsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtsv.f rename to examples/lapack/native/dgtsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtsvx.f b/examples/lapack/native/dgtsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtsvx.f rename to examples/lapack/native/dgtsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgttrf.f b/examples/lapack/native/dgttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgttrf.f rename to examples/lapack/native/dgttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgttrs.f b/examples/lapack/native/dgttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgttrs.f rename to examples/lapack/native/dgttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtts2.f b/examples/lapack/native/dgtts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dgtts2.f rename to examples/lapack/native/dgtts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dhgeqz.f b/examples/lapack/native/dhgeqz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dhgeqz.f rename to examples/lapack/native/dhgeqz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dhsein.f b/examples/lapack/native/dhsein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dhsein.f rename to examples/lapack/native/dhsein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dhseqr.f b/examples/lapack/native/dhseqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dhseqr.f rename to examples/lapack/native/dhseqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/disnan.f b/examples/lapack/native/disnan.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/disnan.f rename to examples/lapack/native/disnan.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbamv.f b/examples/lapack/native/dla_gbamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbamv.f rename to examples/lapack/native/dla_gbamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbrcond.f b/examples/lapack/native/dla_gbrcond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbrcond.f rename to examples/lapack/native/dla_gbrcond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbrfsx_extended.f b/examples/lapack/native/dla_gbrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbrfsx_extended.f rename to examples/lapack/native/dla_gbrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbrpvgrw.f b/examples/lapack/native/dla_gbrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gbrpvgrw.f rename to examples/lapack/native/dla_gbrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_geamv.f b/examples/lapack/native/dla_geamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_geamv.f rename to examples/lapack/native/dla_geamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gercond.f b/examples/lapack/native/dla_gercond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gercond.f rename to examples/lapack/native/dla_gercond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gerfsx_extended.f b/examples/lapack/native/dla_gerfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gerfsx_extended.f rename to examples/lapack/native/dla_gerfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gerpvgrw.f b/examples/lapack/native/dla_gerpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_gerpvgrw.f rename to examples/lapack/native/dla_gerpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_lin_berr.f b/examples/lapack/native/dla_lin_berr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_lin_berr.f rename to examples/lapack/native/dla_lin_berr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_porcond.f b/examples/lapack/native/dla_porcond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_porcond.f rename to examples/lapack/native/dla_porcond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_porfsx_extended.f b/examples/lapack/native/dla_porfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_porfsx_extended.f rename to examples/lapack/native/dla_porfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_porpvgrw.f b/examples/lapack/native/dla_porpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_porpvgrw.f rename to examples/lapack/native/dla_porpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syamv.f b/examples/lapack/native/dla_syamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syamv.f rename to examples/lapack/native/dla_syamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syrcond.f b/examples/lapack/native/dla_syrcond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syrcond.f rename to examples/lapack/native/dla_syrcond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syrfsx_extended.f b/examples/lapack/native/dla_syrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syrfsx_extended.f rename to examples/lapack/native/dla_syrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syrpvgrw.f b/examples/lapack/native/dla_syrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_syrpvgrw.f rename to examples/lapack/native/dla_syrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_wwaddw.f b/examples/lapack/native/dla_wwaddw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dla_wwaddw.f rename to examples/lapack/native/dla_wwaddw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlabad.f b/examples/lapack/native/dlabad.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlabad.f rename to examples/lapack/native/dlabad.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlabrd.f b/examples/lapack/native/dlabrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlabrd.f rename to examples/lapack/native/dlabrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlacn2.f b/examples/lapack/native/dlacn2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlacn2.f rename to examples/lapack/native/dlacn2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlacon.f b/examples/lapack/native/dlacon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlacon.f rename to examples/lapack/native/dlacon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlacpy.f b/examples/lapack/native/dlacpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlacpy.f rename to examples/lapack/native/dlacpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dladiv.f b/examples/lapack/native/dladiv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dladiv.f rename to examples/lapack/native/dladiv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlae2.f b/examples/lapack/native/dlae2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlae2.f rename to examples/lapack/native/dlae2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaebz.f b/examples/lapack/native/dlaebz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaebz.f rename to examples/lapack/native/dlaebz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed0.f b/examples/lapack/native/dlaed0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed0.f rename to examples/lapack/native/dlaed0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed1.f b/examples/lapack/native/dlaed1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed1.f rename to examples/lapack/native/dlaed1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed2.f b/examples/lapack/native/dlaed2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed2.f rename to examples/lapack/native/dlaed2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed3.f b/examples/lapack/native/dlaed3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed3.f rename to examples/lapack/native/dlaed3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed4.f b/examples/lapack/native/dlaed4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed4.f rename to examples/lapack/native/dlaed4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed5.f b/examples/lapack/native/dlaed5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed5.f rename to examples/lapack/native/dlaed5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed6.f b/examples/lapack/native/dlaed6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed6.f rename to examples/lapack/native/dlaed6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed7.f b/examples/lapack/native/dlaed7.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed7.f rename to examples/lapack/native/dlaed7.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed8.f b/examples/lapack/native/dlaed8.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed8.f rename to examples/lapack/native/dlaed8.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed9.f b/examples/lapack/native/dlaed9.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaed9.f rename to examples/lapack/native/dlaed9.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaeda.f b/examples/lapack/native/dlaeda.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaeda.f rename to examples/lapack/native/dlaeda.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaein.f b/examples/lapack/native/dlaein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaein.f rename to examples/lapack/native/dlaein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaev2.f b/examples/lapack/native/dlaev2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaev2.f rename to examples/lapack/native/dlaev2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaexc.f b/examples/lapack/native/dlaexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaexc.f rename to examples/lapack/native/dlaexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlag2.f b/examples/lapack/native/dlag2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlag2.f rename to examples/lapack/native/dlag2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlag2s.f b/examples/lapack/native/dlag2s.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlag2s.f rename to examples/lapack/native/dlag2s.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlags2.f b/examples/lapack/native/dlags2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlags2.f rename to examples/lapack/native/dlags2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagtf.f b/examples/lapack/native/dlagtf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagtf.f rename to examples/lapack/native/dlagtf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagtm.f b/examples/lapack/native/dlagtm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagtm.f rename to examples/lapack/native/dlagtm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagts.f b/examples/lapack/native/dlagts.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagts.f rename to examples/lapack/native/dlagts.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagv2.f b/examples/lapack/native/dlagv2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlagv2.f rename to examples/lapack/native/dlagv2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlahqr.f b/examples/lapack/native/dlahqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlahqr.f rename to examples/lapack/native/dlahqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlahr2.f b/examples/lapack/native/dlahr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlahr2.f rename to examples/lapack/native/dlahr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaic1.f b/examples/lapack/native/dlaic1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaic1.f rename to examples/lapack/native/dlaic1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaisnan.f b/examples/lapack/native/dlaisnan.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaisnan.f rename to examples/lapack/native/dlaisnan.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaln2.f b/examples/lapack/native/dlaln2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaln2.f rename to examples/lapack/native/dlaln2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlals0.f b/examples/lapack/native/dlals0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlals0.f rename to examples/lapack/native/dlals0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlalsa.f b/examples/lapack/native/dlalsa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlalsa.f rename to examples/lapack/native/dlalsa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlalsd.f b/examples/lapack/native/dlalsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlalsd.f rename to examples/lapack/native/dlalsd.f diff --git a/examples/lapack/native/dlamch.f b/examples/lapack/native/dlamch.f new file mode 100644 index 000000000..6d2e24e31 --- /dev/null +++ b/examples/lapack/native/dlamch.f @@ -0,0 +1,39 @@ + DOUBLE PRECISION FUNCTION DLAMCH( CMACH ) + CHARACTER CMACH + DOUBLE PRECISION EPS, SFMIN, BASE, PREC, RND, TINYVAL, HUGEVAL + INTEGER NDIG, MINEXP, MAXEXP + EPS = EPSILON( 0.0D0 ) + BASE = DBLE( RADIX( 0.0D0 ) ) + NDIG = DIGITS( 0.0D0 ) + MINEXP = MINEXPONENT( 0.0D0 ) + MAXEXP = MAXEXPONENT( 0.0D0 ) + TINYVAL = TINY( 0.0D0 ) + HUGEVAL = HUGE( 0.0D0 ) + SFMIN = TINYVAL + PREC = EPS * BASE + RND = 1.0D0 + IF ( CMACH .EQ. 'E' .OR. CMACH .EQ. 'e' ) THEN + DLAMCH = EPS + ELSE IF ( CMACH .EQ. 'S' .OR. CMACH .EQ. 's' ) THEN + DLAMCH = SFMIN + ELSE IF ( CMACH .EQ. 'B' .OR. CMACH .EQ. 'b' ) THEN + DLAMCH = BASE + ELSE IF ( CMACH .EQ. 'P' .OR. CMACH .EQ. 'p' ) THEN + DLAMCH = PREC + ELSE IF ( CMACH .EQ. 'N' .OR. CMACH .EQ. 'n' ) THEN + DLAMCH = DBLE( NDIG ) + ELSE IF ( CMACH .EQ. 'R' .OR. CMACH .EQ. 'r' ) THEN + DLAMCH = RND + ELSE IF ( CMACH .EQ. 'M' .OR. CMACH .EQ. 'm' ) THEN + DLAMCH = DBLE( MINEXP ) + ELSE IF ( CMACH .EQ. 'U' .OR. CMACH .EQ. 'u' ) THEN + DLAMCH = TINYVAL + ELSE IF ( CMACH .EQ. 'L' .OR. CMACH .EQ. 'l' ) THEN + DLAMCH = DBLE( MAXEXP ) + ELSE IF ( CMACH .EQ. 'O' .OR. CMACH .EQ. 'o' ) THEN + DLAMCH = HUGEVAL + ELSE + DLAMCH = 0.0D0 + END IF + RETURN + END diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlamrg.f b/examples/lapack/native/dlamrg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlamrg.f rename to examples/lapack/native/dlamrg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlamswlq.f b/examples/lapack/native/dlamswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlamswlq.f rename to examples/lapack/native/dlamswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlamtsqr.f b/examples/lapack/native/dlamtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlamtsqr.f rename to examples/lapack/native/dlamtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaneg.f b/examples/lapack/native/dlaneg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaneg.f rename to examples/lapack/native/dlaneg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlangb.f b/examples/lapack/native/dlangb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlangb.f rename to examples/lapack/native/dlangb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlange.f b/examples/lapack/native/dlange.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlange.f rename to examples/lapack/native/dlange.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlangt.f b/examples/lapack/native/dlangt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlangt.f rename to examples/lapack/native/dlangt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlanhs.f b/examples/lapack/native/dlanhs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlanhs.f rename to examples/lapack/native/dlanhs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansb.f b/examples/lapack/native/dlansb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansb.f rename to examples/lapack/native/dlansb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansf.f b/examples/lapack/native/dlansf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansf.f rename to examples/lapack/native/dlansf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansp.f b/examples/lapack/native/dlansp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansp.f rename to examples/lapack/native/dlansp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlanst.f b/examples/lapack/native/dlanst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlanst.f rename to examples/lapack/native/dlanst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansy.f b/examples/lapack/native/dlansy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlansy.f rename to examples/lapack/native/dlansy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlantb.f b/examples/lapack/native/dlantb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlantb.f rename to examples/lapack/native/dlantb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlantp.f b/examples/lapack/native/dlantp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlantp.f rename to examples/lapack/native/dlantp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlantr.f b/examples/lapack/native/dlantr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlantr.f rename to examples/lapack/native/dlantr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlanv2.f b/examples/lapack/native/dlanv2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlanv2.f rename to examples/lapack/native/dlanv2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaorhr_col_getrfnp.f b/examples/lapack/native/dlaorhr_col_getrfnp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaorhr_col_getrfnp.f rename to examples/lapack/native/dlaorhr_col_getrfnp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaorhr_col_getrfnp2.f b/examples/lapack/native/dlaorhr_col_getrfnp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaorhr_col_getrfnp2.f rename to examples/lapack/native/dlaorhr_col_getrfnp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapll.f b/examples/lapack/native/dlapll.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapll.f rename to examples/lapack/native/dlapll.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapmr.f b/examples/lapack/native/dlapmr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapmr.f rename to examples/lapack/native/dlapmr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapmt.f b/examples/lapack/native/dlapmt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapmt.f rename to examples/lapack/native/dlapmt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapy2.f b/examples/lapack/native/dlapy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapy2.f rename to examples/lapack/native/dlapy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapy3.f b/examples/lapack/native/dlapy3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlapy3.f rename to examples/lapack/native/dlapy3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqgb.f b/examples/lapack/native/dlaqgb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqgb.f rename to examples/lapack/native/dlaqgb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqge.f b/examples/lapack/native/dlaqge.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqge.f rename to examples/lapack/native/dlaqge.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqp2.f b/examples/lapack/native/dlaqp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqp2.f rename to examples/lapack/native/dlaqp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqp2rk.f b/examples/lapack/native/dlaqp2rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqp2rk.f rename to examples/lapack/native/dlaqp2rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqp3rk.f b/examples/lapack/native/dlaqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqp3rk.f rename to examples/lapack/native/dlaqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqps.f b/examples/lapack/native/dlaqps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqps.f rename to examples/lapack/native/dlaqps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr0.f b/examples/lapack/native/dlaqr0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr0.f rename to examples/lapack/native/dlaqr0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr1.f b/examples/lapack/native/dlaqr1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr1.f rename to examples/lapack/native/dlaqr1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr2.f b/examples/lapack/native/dlaqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr2.f rename to examples/lapack/native/dlaqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr3.f b/examples/lapack/native/dlaqr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr3.f rename to examples/lapack/native/dlaqr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr4.f b/examples/lapack/native/dlaqr4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr4.f rename to examples/lapack/native/dlaqr4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr5.f b/examples/lapack/native/dlaqr5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqr5.f rename to examples/lapack/native/dlaqr5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqsb.f b/examples/lapack/native/dlaqsb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqsb.f rename to examples/lapack/native/dlaqsb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqsp.f b/examples/lapack/native/dlaqsp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqsp.f rename to examples/lapack/native/dlaqsp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqsy.f b/examples/lapack/native/dlaqsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqsy.f rename to examples/lapack/native/dlaqsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqtr.f b/examples/lapack/native/dlaqtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqtr.f rename to examples/lapack/native/dlaqtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz0.f b/examples/lapack/native/dlaqz0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz0.f rename to examples/lapack/native/dlaqz0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz1.f b/examples/lapack/native/dlaqz1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz1.f rename to examples/lapack/native/dlaqz1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz2.f b/examples/lapack/native/dlaqz2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz2.f rename to examples/lapack/native/dlaqz2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz3.f b/examples/lapack/native/dlaqz3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz3.f rename to examples/lapack/native/dlaqz3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz4.f b/examples/lapack/native/dlaqz4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaqz4.f rename to examples/lapack/native/dlaqz4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlar1v.f b/examples/lapack/native/dlar1v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlar1v.f rename to examples/lapack/native/dlar1v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlar2v.f b/examples/lapack/native/dlar2v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlar2v.f rename to examples/lapack/native/dlar2v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarf.f b/examples/lapack/native/dlarf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarf.f rename to examples/lapack/native/dlarf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarf1f.f b/examples/lapack/native/dlarf1f.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarf1f.f rename to examples/lapack/native/dlarf1f.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarf1l.f b/examples/lapack/native/dlarf1l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarf1l.f rename to examples/lapack/native/dlarf1l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfb.f b/examples/lapack/native/dlarfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfb.f rename to examples/lapack/native/dlarfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfb_gett.f b/examples/lapack/native/dlarfb_gett.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfb_gett.f rename to examples/lapack/native/dlarfb_gett.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfg.f b/examples/lapack/native/dlarfg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfg.f rename to examples/lapack/native/dlarfg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfgp.f b/examples/lapack/native/dlarfgp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfgp.f rename to examples/lapack/native/dlarfgp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarft.f b/examples/lapack/native/dlarft.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarft.f rename to examples/lapack/native/dlarft.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfx.f b/examples/lapack/native/dlarfx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfx.f rename to examples/lapack/native/dlarfx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfy.f b/examples/lapack/native/dlarfy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarfy.f rename to examples/lapack/native/dlarfy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlargv.f b/examples/lapack/native/dlargv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlargv.f rename to examples/lapack/native/dlargv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarmm.f b/examples/lapack/native/dlarmm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarmm.f rename to examples/lapack/native/dlarmm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarnv.f b/examples/lapack/native/dlarnv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarnv.f rename to examples/lapack/native/dlarnv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarra.f b/examples/lapack/native/dlarra.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarra.f rename to examples/lapack/native/dlarra.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrb.f b/examples/lapack/native/dlarrb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrb.f rename to examples/lapack/native/dlarrb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrc.f b/examples/lapack/native/dlarrc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrc.f rename to examples/lapack/native/dlarrc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrd.f b/examples/lapack/native/dlarrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrd.f rename to examples/lapack/native/dlarrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarre.f b/examples/lapack/native/dlarre.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarre.f rename to examples/lapack/native/dlarre.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrf.f b/examples/lapack/native/dlarrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrf.f rename to examples/lapack/native/dlarrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrj.f b/examples/lapack/native/dlarrj.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrj.f rename to examples/lapack/native/dlarrj.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrk.f b/examples/lapack/native/dlarrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrk.f rename to examples/lapack/native/dlarrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrr.f b/examples/lapack/native/dlarrr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrr.f rename to examples/lapack/native/dlarrr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrv.f b/examples/lapack/native/dlarrv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarrv.f rename to examples/lapack/native/dlarrv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarscl2.f b/examples/lapack/native/dlarscl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarscl2.f rename to examples/lapack/native/dlarscl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartg.f90 b/examples/lapack/native/dlartg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartg.f90 rename to examples/lapack/native/dlartg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartgp.f b/examples/lapack/native/dlartgp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartgp.f rename to examples/lapack/native/dlartgp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartgs.f b/examples/lapack/native/dlartgs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartgs.f rename to examples/lapack/native/dlartgs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartv.f b/examples/lapack/native/dlartv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlartv.f rename to examples/lapack/native/dlartv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaruv.f b/examples/lapack/native/dlaruv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaruv.f rename to examples/lapack/native/dlaruv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarz.f b/examples/lapack/native/dlarz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarz.f rename to examples/lapack/native/dlarz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarzb.f b/examples/lapack/native/dlarzb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarzb.f rename to examples/lapack/native/dlarzb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarzt.f b/examples/lapack/native/dlarzt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlarzt.f rename to examples/lapack/native/dlarzt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlas2.f b/examples/lapack/native/dlas2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlas2.f rename to examples/lapack/native/dlas2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlascl.f b/examples/lapack/native/dlascl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlascl.f rename to examples/lapack/native/dlascl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlascl2.f b/examples/lapack/native/dlascl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlascl2.f rename to examples/lapack/native/dlascl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd0.f b/examples/lapack/native/dlasd0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd0.f rename to examples/lapack/native/dlasd0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd1.f b/examples/lapack/native/dlasd1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd1.f rename to examples/lapack/native/dlasd1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd2.f b/examples/lapack/native/dlasd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd2.f rename to examples/lapack/native/dlasd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd3.f b/examples/lapack/native/dlasd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd3.f rename to examples/lapack/native/dlasd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd4.f b/examples/lapack/native/dlasd4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd4.f rename to examples/lapack/native/dlasd4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd5.f b/examples/lapack/native/dlasd5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd5.f rename to examples/lapack/native/dlasd5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd6.f b/examples/lapack/native/dlasd6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd6.f rename to examples/lapack/native/dlasd6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd7.f b/examples/lapack/native/dlasd7.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd7.f rename to examples/lapack/native/dlasd7.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd8.f b/examples/lapack/native/dlasd8.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasd8.f rename to examples/lapack/native/dlasd8.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasda.f b/examples/lapack/native/dlasda.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasda.f rename to examples/lapack/native/dlasda.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasdq.f b/examples/lapack/native/dlasdq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasdq.f rename to examples/lapack/native/dlasdq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasdt.f b/examples/lapack/native/dlasdt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasdt.f rename to examples/lapack/native/dlasdt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaset.f b/examples/lapack/native/dlaset.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaset.f rename to examples/lapack/native/dlaset.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq1.f b/examples/lapack/native/dlasq1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq1.f rename to examples/lapack/native/dlasq1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq2.f b/examples/lapack/native/dlasq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq2.f rename to examples/lapack/native/dlasq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq3.f b/examples/lapack/native/dlasq3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq3.f rename to examples/lapack/native/dlasq3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq4.f b/examples/lapack/native/dlasq4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq4.f rename to examples/lapack/native/dlasq4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq5.f b/examples/lapack/native/dlasq5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq5.f rename to examples/lapack/native/dlasq5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq6.f b/examples/lapack/native/dlasq6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasq6.f rename to examples/lapack/native/dlasq6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasr.f b/examples/lapack/native/dlasr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasr.f rename to examples/lapack/native/dlasr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasrt.f b/examples/lapack/native/dlasrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasrt.f rename to examples/lapack/native/dlasrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlassq.f90 b/examples/lapack/native/dlassq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlassq.f90 rename to examples/lapack/native/dlassq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasv2.f b/examples/lapack/native/dlasv2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasv2.f rename to examples/lapack/native/dlasv2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaswlq.f b/examples/lapack/native/dlaswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaswlq.f rename to examples/lapack/native/dlaswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaswp.f b/examples/lapack/native/dlaswp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlaswp.f rename to examples/lapack/native/dlaswp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasy2.f b/examples/lapack/native/dlasy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasy2.f rename to examples/lapack/native/dlasy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf.f b/examples/lapack/native/dlasyf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf.f rename to examples/lapack/native/dlasyf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf_aa.f b/examples/lapack/native/dlasyf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf_aa.f rename to examples/lapack/native/dlasyf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf_rk.f b/examples/lapack/native/dlasyf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf_rk.f rename to examples/lapack/native/dlasyf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf_rook.f b/examples/lapack/native/dlasyf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlasyf_rook.f rename to examples/lapack/native/dlasyf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlat2s.f b/examples/lapack/native/dlat2s.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlat2s.f rename to examples/lapack/native/dlat2s.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatbs.f b/examples/lapack/native/dlatbs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatbs.f rename to examples/lapack/native/dlatbs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatdf.f b/examples/lapack/native/dlatdf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatdf.f rename to examples/lapack/native/dlatdf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatps.f b/examples/lapack/native/dlatps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatps.f rename to examples/lapack/native/dlatps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrd.f b/examples/lapack/native/dlatrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrd.f rename to examples/lapack/native/dlatrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrs.f b/examples/lapack/native/dlatrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrs.f rename to examples/lapack/native/dlatrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrs3.f b/examples/lapack/native/dlatrs3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrs3.f rename to examples/lapack/native/dlatrs3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrz.f b/examples/lapack/native/dlatrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatrz.f rename to examples/lapack/native/dlatrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatsqr.f b/examples/lapack/native/dlatsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlatsqr.f rename to examples/lapack/native/dlatsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlauu2.f b/examples/lapack/native/dlauu2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlauu2.f rename to examples/lapack/native/dlauu2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlauum.f b/examples/lapack/native/dlauum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dlauum.f rename to examples/lapack/native/dlauum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dopgtr.f b/examples/lapack/native/dopgtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dopgtr.f rename to examples/lapack/native/dopgtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dopmtr.f b/examples/lapack/native/dopmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dopmtr.f rename to examples/lapack/native/dopmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb.f b/examples/lapack/native/dorbdb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb.f rename to examples/lapack/native/dorbdb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb1.f b/examples/lapack/native/dorbdb1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb1.f rename to examples/lapack/native/dorbdb1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb2.f b/examples/lapack/native/dorbdb2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb2.f rename to examples/lapack/native/dorbdb2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb3.f b/examples/lapack/native/dorbdb3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb3.f rename to examples/lapack/native/dorbdb3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb4.f b/examples/lapack/native/dorbdb4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb4.f rename to examples/lapack/native/dorbdb4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb5.f b/examples/lapack/native/dorbdb5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb5.f rename to examples/lapack/native/dorbdb5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb6.f b/examples/lapack/native/dorbdb6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorbdb6.f rename to examples/lapack/native/dorbdb6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorcsd.f b/examples/lapack/native/dorcsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorcsd.f rename to examples/lapack/native/dorcsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorcsd2by1.f b/examples/lapack/native/dorcsd2by1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorcsd2by1.f rename to examples/lapack/native/dorcsd2by1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorg2l.f b/examples/lapack/native/dorg2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorg2l.f rename to examples/lapack/native/dorg2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorg2r.f b/examples/lapack/native/dorg2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorg2r.f rename to examples/lapack/native/dorg2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgbr.f b/examples/lapack/native/dorgbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgbr.f rename to examples/lapack/native/dorgbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorghr.f b/examples/lapack/native/dorghr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorghr.f rename to examples/lapack/native/dorghr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgl2.f b/examples/lapack/native/dorgl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgl2.f rename to examples/lapack/native/dorgl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorglq.f b/examples/lapack/native/dorglq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorglq.f rename to examples/lapack/native/dorglq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgql.f b/examples/lapack/native/dorgql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgql.f rename to examples/lapack/native/dorgql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgqr.f b/examples/lapack/native/dorgqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgqr.f rename to examples/lapack/native/dorgqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgr2.f b/examples/lapack/native/dorgr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgr2.f rename to examples/lapack/native/dorgr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgrq.f b/examples/lapack/native/dorgrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgrq.f rename to examples/lapack/native/dorgrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgtr.f b/examples/lapack/native/dorgtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgtr.f rename to examples/lapack/native/dorgtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgtsqr.f b/examples/lapack/native/dorgtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgtsqr.f rename to examples/lapack/native/dorgtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgtsqr_row.f b/examples/lapack/native/dorgtsqr_row.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorgtsqr_row.f rename to examples/lapack/native/dorgtsqr_row.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorhr_col.f b/examples/lapack/native/dorhr_col.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorhr_col.f rename to examples/lapack/native/dorhr_col.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorm22.f b/examples/lapack/native/dorm22.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorm22.f rename to examples/lapack/native/dorm22.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorm2l.f b/examples/lapack/native/dorm2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorm2l.f rename to examples/lapack/native/dorm2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorm2r.f b/examples/lapack/native/dorm2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorm2r.f rename to examples/lapack/native/dorm2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormbr.f b/examples/lapack/native/dormbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormbr.f rename to examples/lapack/native/dormbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormhr.f b/examples/lapack/native/dormhr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormhr.f rename to examples/lapack/native/dormhr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorml2.f b/examples/lapack/native/dorml2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dorml2.f rename to examples/lapack/native/dorml2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormlq.f b/examples/lapack/native/dormlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormlq.f rename to examples/lapack/native/dormlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormql.f b/examples/lapack/native/dormql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormql.f rename to examples/lapack/native/dormql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormqr.f b/examples/lapack/native/dormqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormqr.f rename to examples/lapack/native/dormqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormr2.f b/examples/lapack/native/dormr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormr2.f rename to examples/lapack/native/dormr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormr3.f b/examples/lapack/native/dormr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormr3.f rename to examples/lapack/native/dormr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormrq.f b/examples/lapack/native/dormrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormrq.f rename to examples/lapack/native/dormrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormrz.f b/examples/lapack/native/dormrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormrz.f rename to examples/lapack/native/dormrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormtr.f b/examples/lapack/native/dormtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dormtr.f rename to examples/lapack/native/dormtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbcon.f b/examples/lapack/native/dpbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbcon.f rename to examples/lapack/native/dpbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbequ.f b/examples/lapack/native/dpbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbequ.f rename to examples/lapack/native/dpbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbrfs.f b/examples/lapack/native/dpbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbrfs.f rename to examples/lapack/native/dpbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbstf.f b/examples/lapack/native/dpbstf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbstf.f rename to examples/lapack/native/dpbstf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbsv.f b/examples/lapack/native/dpbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbsv.f rename to examples/lapack/native/dpbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbsvx.f b/examples/lapack/native/dpbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbsvx.f rename to examples/lapack/native/dpbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbtf2.f b/examples/lapack/native/dpbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbtf2.f rename to examples/lapack/native/dpbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbtrf.f b/examples/lapack/native/dpbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbtrf.f rename to examples/lapack/native/dpbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbtrs.f b/examples/lapack/native/dpbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpbtrs.f rename to examples/lapack/native/dpbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpftrf.f b/examples/lapack/native/dpftrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpftrf.f rename to examples/lapack/native/dpftrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpftri.f b/examples/lapack/native/dpftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpftri.f rename to examples/lapack/native/dpftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpftrs.f b/examples/lapack/native/dpftrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpftrs.f rename to examples/lapack/native/dpftrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpocon.f b/examples/lapack/native/dpocon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpocon.f rename to examples/lapack/native/dpocon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpoequ.f b/examples/lapack/native/dpoequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpoequ.f rename to examples/lapack/native/dpoequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpoequb.f b/examples/lapack/native/dpoequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpoequb.f rename to examples/lapack/native/dpoequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dporfs.f b/examples/lapack/native/dporfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dporfs.f rename to examples/lapack/native/dporfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dporfsx.f b/examples/lapack/native/dporfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dporfsx.f rename to examples/lapack/native/dporfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dposv.f b/examples/lapack/native/dposv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dposv.f rename to examples/lapack/native/dposv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dposvx.f b/examples/lapack/native/dposvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dposvx.f rename to examples/lapack/native/dposvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dposvxx.f b/examples/lapack/native/dposvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dposvxx.f rename to examples/lapack/native/dposvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotf2.f b/examples/lapack/native/dpotf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotf2.f rename to examples/lapack/native/dpotf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotrf.f b/examples/lapack/native/dpotrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotrf.f rename to examples/lapack/native/dpotrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotrf2.f b/examples/lapack/native/dpotrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotrf2.f rename to examples/lapack/native/dpotrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotri.f b/examples/lapack/native/dpotri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotri.f rename to examples/lapack/native/dpotri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotrs.f b/examples/lapack/native/dpotrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpotrs.f rename to examples/lapack/native/dpotrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppcon.f b/examples/lapack/native/dppcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppcon.f rename to examples/lapack/native/dppcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppequ.f b/examples/lapack/native/dppequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppequ.f rename to examples/lapack/native/dppequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpprfs.f b/examples/lapack/native/dpprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpprfs.f rename to examples/lapack/native/dpprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppsv.f b/examples/lapack/native/dppsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppsv.f rename to examples/lapack/native/dppsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppsvx.f b/examples/lapack/native/dppsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dppsvx.f rename to examples/lapack/native/dppsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpptrf.f b/examples/lapack/native/dpptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpptrf.f rename to examples/lapack/native/dpptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpptri.f b/examples/lapack/native/dpptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpptri.f rename to examples/lapack/native/dpptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpptrs.f b/examples/lapack/native/dpptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpptrs.f rename to examples/lapack/native/dpptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpstf2.f b/examples/lapack/native/dpstf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpstf2.f rename to examples/lapack/native/dpstf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpstrf.f b/examples/lapack/native/dpstrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpstrf.f rename to examples/lapack/native/dpstrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptcon.f b/examples/lapack/native/dptcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptcon.f rename to examples/lapack/native/dptcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpteqr.f b/examples/lapack/native/dpteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpteqr.f rename to examples/lapack/native/dpteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptrfs.f b/examples/lapack/native/dptrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptrfs.f rename to examples/lapack/native/dptrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptsv.f b/examples/lapack/native/dptsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptsv.f rename to examples/lapack/native/dptsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptsvx.f b/examples/lapack/native/dptsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptsvx.f rename to examples/lapack/native/dptsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpttrf.f b/examples/lapack/native/dpttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpttrf.f rename to examples/lapack/native/dpttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpttrs.f b/examples/lapack/native/dpttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dpttrs.f rename to examples/lapack/native/dpttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptts2.f b/examples/lapack/native/dptts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dptts2.f rename to examples/lapack/native/dptts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/drscl.f b/examples/lapack/native/drscl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/drscl.f rename to examples/lapack/native/drscl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsb2st_kernels.f b/examples/lapack/native/dsb2st_kernels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsb2st_kernels.f rename to examples/lapack/native/dsb2st_kernels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbev.f b/examples/lapack/native/dsbev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbev.f rename to examples/lapack/native/dsbev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbev_2stage.f b/examples/lapack/native/dsbev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbev_2stage.f rename to examples/lapack/native/dsbev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevd.f b/examples/lapack/native/dsbevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevd.f rename to examples/lapack/native/dsbevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevd_2stage.f b/examples/lapack/native/dsbevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevd_2stage.f rename to examples/lapack/native/dsbevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevx.f b/examples/lapack/native/dsbevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevx.f rename to examples/lapack/native/dsbevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevx_2stage.f b/examples/lapack/native/dsbevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbevx_2stage.f rename to examples/lapack/native/dsbevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgst.f b/examples/lapack/native/dsbgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgst.f rename to examples/lapack/native/dsbgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgv.f b/examples/lapack/native/dsbgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgv.f rename to examples/lapack/native/dsbgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgvd.f b/examples/lapack/native/dsbgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgvd.f rename to examples/lapack/native/dsbgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgvx.f b/examples/lapack/native/dsbgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbgvx.f rename to examples/lapack/native/dsbgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbtrd.f b/examples/lapack/native/dsbtrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsbtrd.f rename to examples/lapack/native/dsbtrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsfrk.f b/examples/lapack/native/dsfrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsfrk.f rename to examples/lapack/native/dsfrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsgesv.f b/examples/lapack/native/dsgesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsgesv.f rename to examples/lapack/native/dsgesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspcon.f b/examples/lapack/native/dspcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspcon.f rename to examples/lapack/native/dspcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspev.f b/examples/lapack/native/dspev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspev.f rename to examples/lapack/native/dspev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspevd.f b/examples/lapack/native/dspevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspevd.f rename to examples/lapack/native/dspevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspevx.f b/examples/lapack/native/dspevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspevx.f rename to examples/lapack/native/dspevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgst.f b/examples/lapack/native/dspgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgst.f rename to examples/lapack/native/dspgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgv.f b/examples/lapack/native/dspgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgv.f rename to examples/lapack/native/dspgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgvd.f b/examples/lapack/native/dspgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgvd.f rename to examples/lapack/native/dspgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgvx.f b/examples/lapack/native/dspgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspgvx.f rename to examples/lapack/native/dspgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsposv.f b/examples/lapack/native/dsposv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsposv.f rename to examples/lapack/native/dsposv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsprfs.f b/examples/lapack/native/dsprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsprfs.f rename to examples/lapack/native/dsprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspsv.f b/examples/lapack/native/dspsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspsv.f rename to examples/lapack/native/dspsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspsvx.f b/examples/lapack/native/dspsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dspsvx.f rename to examples/lapack/native/dspsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptrd.f b/examples/lapack/native/dsptrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptrd.f rename to examples/lapack/native/dsptrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptrf.f b/examples/lapack/native/dsptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptrf.f rename to examples/lapack/native/dsptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptri.f b/examples/lapack/native/dsptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptri.f rename to examples/lapack/native/dsptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptrs.f b/examples/lapack/native/dsptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsptrs.f rename to examples/lapack/native/dsptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstebz.f b/examples/lapack/native/dstebz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstebz.f rename to examples/lapack/native/dstebz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstedc.f b/examples/lapack/native/dstedc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstedc.f rename to examples/lapack/native/dstedc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstegr.f b/examples/lapack/native/dstegr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstegr.f rename to examples/lapack/native/dstegr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstein.f b/examples/lapack/native/dstein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstein.f rename to examples/lapack/native/dstein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstemr.f b/examples/lapack/native/dstemr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstemr.f rename to examples/lapack/native/dstemr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsteqr.f b/examples/lapack/native/dsteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsteqr.f rename to examples/lapack/native/dsteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsterf.f b/examples/lapack/native/dsterf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsterf.f rename to examples/lapack/native/dsterf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstev.f b/examples/lapack/native/dstev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstev.f rename to examples/lapack/native/dstev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstevd.f b/examples/lapack/native/dstevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstevd.f rename to examples/lapack/native/dstevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstevr.f b/examples/lapack/native/dstevr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstevr.f rename to examples/lapack/native/dstevr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstevx.f b/examples/lapack/native/dstevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dstevx.f rename to examples/lapack/native/dstevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsycon.f b/examples/lapack/native/dsycon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsycon.f rename to examples/lapack/native/dsycon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsycon_3.f b/examples/lapack/native/dsycon_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsycon_3.f rename to examples/lapack/native/dsycon_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsycon_rook.f b/examples/lapack/native/dsycon_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsycon_rook.f rename to examples/lapack/native/dsycon_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyconv.f b/examples/lapack/native/dsyconv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyconv.f rename to examples/lapack/native/dsyconv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyconvf.f b/examples/lapack/native/dsyconvf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyconvf.f rename to examples/lapack/native/dsyconvf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyconvf_rook.f b/examples/lapack/native/dsyconvf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyconvf_rook.f rename to examples/lapack/native/dsyconvf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyequb.f b/examples/lapack/native/dsyequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyequb.f rename to examples/lapack/native/dsyequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyev.f b/examples/lapack/native/dsyev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyev.f rename to examples/lapack/native/dsyev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyev_2stage.f b/examples/lapack/native/dsyev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyev_2stage.f rename to examples/lapack/native/dsyev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevd.f b/examples/lapack/native/dsyevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevd.f rename to examples/lapack/native/dsyevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevd_2stage.f b/examples/lapack/native/dsyevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevd_2stage.f rename to examples/lapack/native/dsyevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevr.f b/examples/lapack/native/dsyevr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevr.f rename to examples/lapack/native/dsyevr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevr_2stage.f b/examples/lapack/native/dsyevr_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevr_2stage.f rename to examples/lapack/native/dsyevr_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevx.f b/examples/lapack/native/dsyevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevx.f rename to examples/lapack/native/dsyevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevx_2stage.f b/examples/lapack/native/dsyevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyevx_2stage.f rename to examples/lapack/native/dsyevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygs2.f b/examples/lapack/native/dsygs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygs2.f rename to examples/lapack/native/dsygs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygst.f b/examples/lapack/native/dsygst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygst.f rename to examples/lapack/native/dsygst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygv.f b/examples/lapack/native/dsygv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygv.f rename to examples/lapack/native/dsygv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygv_2stage.f b/examples/lapack/native/dsygv_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygv_2stage.f rename to examples/lapack/native/dsygv_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygvd.f b/examples/lapack/native/dsygvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygvd.f rename to examples/lapack/native/dsygvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygvx.f b/examples/lapack/native/dsygvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsygvx.f rename to examples/lapack/native/dsygvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyrfs.f b/examples/lapack/native/dsyrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyrfs.f rename to examples/lapack/native/dsyrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyrfsx.f b/examples/lapack/native/dsyrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyrfsx.f rename to examples/lapack/native/dsyrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv.f b/examples/lapack/native/dsysv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv.f rename to examples/lapack/native/dsysv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_aa.f b/examples/lapack/native/dsysv_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_aa.f rename to examples/lapack/native/dsysv_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_aa_2stage.f b/examples/lapack/native/dsysv_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_aa_2stage.f rename to examples/lapack/native/dsysv_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_rk.f b/examples/lapack/native/dsysv_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_rk.f rename to examples/lapack/native/dsysv_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_rook.f b/examples/lapack/native/dsysv_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysv_rook.f rename to examples/lapack/native/dsysv_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysvx.f b/examples/lapack/native/dsysvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysvx.f rename to examples/lapack/native/dsysvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysvxx.f b/examples/lapack/native/dsysvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsysvxx.f rename to examples/lapack/native/dsysvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyswapr.f b/examples/lapack/native/dsyswapr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsyswapr.f rename to examples/lapack/native/dsyswapr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytd2.f b/examples/lapack/native/dsytd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytd2.f rename to examples/lapack/native/dsytd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytf2.f b/examples/lapack/native/dsytf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytf2.f rename to examples/lapack/native/dsytf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytf2_rk.f b/examples/lapack/native/dsytf2_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytf2_rk.f rename to examples/lapack/native/dsytf2_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytf2_rook.f b/examples/lapack/native/dsytf2_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytf2_rook.f rename to examples/lapack/native/dsytf2_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd.f b/examples/lapack/native/dsytrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd.f rename to examples/lapack/native/dsytrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd_2stage.f b/examples/lapack/native/dsytrd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd_2stage.f rename to examples/lapack/native/dsytrd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd_sb2st.F b/examples/lapack/native/dsytrd_sb2st.F similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd_sb2st.F rename to examples/lapack/native/dsytrd_sb2st.F diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd_sy2sb.f b/examples/lapack/native/dsytrd_sy2sb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrd_sy2sb.f rename to examples/lapack/native/dsytrd_sy2sb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf.f b/examples/lapack/native/dsytrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf.f rename to examples/lapack/native/dsytrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_aa.f b/examples/lapack/native/dsytrf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_aa.f rename to examples/lapack/native/dsytrf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_aa_2stage.f b/examples/lapack/native/dsytrf_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_aa_2stage.f rename to examples/lapack/native/dsytrf_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_rk.f b/examples/lapack/native/dsytrf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_rk.f rename to examples/lapack/native/dsytrf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_rook.f b/examples/lapack/native/dsytrf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrf_rook.f rename to examples/lapack/native/dsytrf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri.f b/examples/lapack/native/dsytri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri.f rename to examples/lapack/native/dsytri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri2.f b/examples/lapack/native/dsytri2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri2.f rename to examples/lapack/native/dsytri2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri2x.f b/examples/lapack/native/dsytri2x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri2x.f rename to examples/lapack/native/dsytri2x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri_3.f b/examples/lapack/native/dsytri_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri_3.f rename to examples/lapack/native/dsytri_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri_3x.f b/examples/lapack/native/dsytri_3x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri_3x.f rename to examples/lapack/native/dsytri_3x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri_rook.f b/examples/lapack/native/dsytri_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytri_rook.f rename to examples/lapack/native/dsytri_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs.f b/examples/lapack/native/dsytrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs.f rename to examples/lapack/native/dsytrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs2.f b/examples/lapack/native/dsytrs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs2.f rename to examples/lapack/native/dsytrs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_3.f b/examples/lapack/native/dsytrs_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_3.f rename to examples/lapack/native/dsytrs_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_aa.f b/examples/lapack/native/dsytrs_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_aa.f rename to examples/lapack/native/dsytrs_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_aa_2stage.f b/examples/lapack/native/dsytrs_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_aa_2stage.f rename to examples/lapack/native/dsytrs_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_rook.f b/examples/lapack/native/dsytrs_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dsytrs_rook.f rename to examples/lapack/native/dsytrs_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtbcon.f b/examples/lapack/native/dtbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtbcon.f rename to examples/lapack/native/dtbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtbrfs.f b/examples/lapack/native/dtbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtbrfs.f rename to examples/lapack/native/dtbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtbtrs.f b/examples/lapack/native/dtbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtbtrs.f rename to examples/lapack/native/dtbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtfsm.f b/examples/lapack/native/dtfsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtfsm.f rename to examples/lapack/native/dtfsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtftri.f b/examples/lapack/native/dtftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtftri.f rename to examples/lapack/native/dtftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtfttp.f b/examples/lapack/native/dtfttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtfttp.f rename to examples/lapack/native/dtfttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtfttr.f b/examples/lapack/native/dtfttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtfttr.f rename to examples/lapack/native/dtfttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgevc.f b/examples/lapack/native/dtgevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgevc.f rename to examples/lapack/native/dtgevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgex2.f b/examples/lapack/native/dtgex2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgex2.f rename to examples/lapack/native/dtgex2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgexc.f b/examples/lapack/native/dtgexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgexc.f rename to examples/lapack/native/dtgexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsen.f b/examples/lapack/native/dtgsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsen.f rename to examples/lapack/native/dtgsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsja.f b/examples/lapack/native/dtgsja.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsja.f rename to examples/lapack/native/dtgsja.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsna.f b/examples/lapack/native/dtgsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsna.f rename to examples/lapack/native/dtgsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsy2.f b/examples/lapack/native/dtgsy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsy2.f rename to examples/lapack/native/dtgsy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsyl.f b/examples/lapack/native/dtgsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtgsyl.f rename to examples/lapack/native/dtgsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpcon.f b/examples/lapack/native/dtpcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpcon.f rename to examples/lapack/native/dtpcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtplqt.f b/examples/lapack/native/dtplqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtplqt.f rename to examples/lapack/native/dtplqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtplqt2.f b/examples/lapack/native/dtplqt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtplqt2.f rename to examples/lapack/native/dtplqt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpmlqt.f b/examples/lapack/native/dtpmlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpmlqt.f rename to examples/lapack/native/dtpmlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpmqrt.f b/examples/lapack/native/dtpmqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpmqrt.f rename to examples/lapack/native/dtpmqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpqrt.f b/examples/lapack/native/dtpqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpqrt.f rename to examples/lapack/native/dtpqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpqrt2.f b/examples/lapack/native/dtpqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpqrt2.f rename to examples/lapack/native/dtpqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtprfb.f b/examples/lapack/native/dtprfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtprfb.f rename to examples/lapack/native/dtprfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtprfs.f b/examples/lapack/native/dtprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtprfs.f rename to examples/lapack/native/dtprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtptri.f b/examples/lapack/native/dtptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtptri.f rename to examples/lapack/native/dtptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtptrs.f b/examples/lapack/native/dtptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtptrs.f rename to examples/lapack/native/dtptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpttf.f b/examples/lapack/native/dtpttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpttf.f rename to examples/lapack/native/dtpttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpttr.f b/examples/lapack/native/dtpttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtpttr.f rename to examples/lapack/native/dtpttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrcon.f b/examples/lapack/native/dtrcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrcon.f rename to examples/lapack/native/dtrcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrevc.f b/examples/lapack/native/dtrevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrevc.f rename to examples/lapack/native/dtrevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrevc3.f b/examples/lapack/native/dtrevc3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrevc3.f rename to examples/lapack/native/dtrevc3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrexc.f b/examples/lapack/native/dtrexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrexc.f rename to examples/lapack/native/dtrexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrrfs.f b/examples/lapack/native/dtrrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrrfs.f rename to examples/lapack/native/dtrrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsen.f b/examples/lapack/native/dtrsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsen.f rename to examples/lapack/native/dtrsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsna.f b/examples/lapack/native/dtrsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsna.f rename to examples/lapack/native/dtrsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsyl.f b/examples/lapack/native/dtrsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsyl.f rename to examples/lapack/native/dtrsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsyl3.f b/examples/lapack/native/dtrsyl3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrsyl3.f rename to examples/lapack/native/dtrsyl3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrti2.f b/examples/lapack/native/dtrti2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrti2.f rename to examples/lapack/native/dtrti2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrtri.f b/examples/lapack/native/dtrtri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrtri.f rename to examples/lapack/native/dtrtri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrtrs.f b/examples/lapack/native/dtrtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrtrs.f rename to examples/lapack/native/dtrtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrttf.f b/examples/lapack/native/dtrttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrttf.f rename to examples/lapack/native/dtrttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrttp.f b/examples/lapack/native/dtrttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtrttp.f rename to examples/lapack/native/dtrttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtzrzf.f b/examples/lapack/native/dtzrzf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dtzrzf.f rename to examples/lapack/native/dtzrzf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dzsum1.f b/examples/lapack/native/dzsum1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/dzsum1.f rename to examples/lapack/native/dzsum1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/icmax1.f b/examples/lapack/native/icmax1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/icmax1.f rename to examples/lapack/native/icmax1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ieeeck.f b/examples/lapack/native/ieeeck.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ieeeck.f rename to examples/lapack/native/ieeeck.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaclc.f b/examples/lapack/native/ilaclc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaclc.f rename to examples/lapack/native/ilaclc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaclr.f b/examples/lapack/native/ilaclr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaclr.f rename to examples/lapack/native/ilaclr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iladiag.f b/examples/lapack/native/iladiag.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iladiag.f rename to examples/lapack/native/iladiag.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iladlc.f b/examples/lapack/native/iladlc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iladlc.f rename to examples/lapack/native/iladlc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iladlr.f b/examples/lapack/native/iladlr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iladlr.f rename to examples/lapack/native/iladlr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaenv.f b/examples/lapack/native/ilaenv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaenv.f rename to examples/lapack/native/ilaenv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaenv2stage.f b/examples/lapack/native/ilaenv2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaenv2stage.f rename to examples/lapack/native/ilaenv2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaprec.f b/examples/lapack/native/ilaprec.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaprec.f rename to examples/lapack/native/ilaprec.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaslc.f b/examples/lapack/native/ilaslc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaslc.f rename to examples/lapack/native/ilaslc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaslr.f b/examples/lapack/native/ilaslr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilaslr.f rename to examples/lapack/native/ilaslr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilatrans.f b/examples/lapack/native/ilatrans.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilatrans.f rename to examples/lapack/native/ilatrans.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilauplo.f b/examples/lapack/native/ilauplo.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilauplo.f rename to examples/lapack/native/ilauplo.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilazlc.f b/examples/lapack/native/ilazlc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilazlc.f rename to examples/lapack/native/ilazlc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilazlr.f b/examples/lapack/native/ilazlr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ilazlr.f rename to examples/lapack/native/ilazlr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iparam2stage.F b/examples/lapack/native/iparam2stage.F similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iparam2stage.F rename to examples/lapack/native/iparam2stage.F diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iparmq.f b/examples/lapack/native/iparmq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/iparmq.f rename to examples/lapack/native/iparmq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/izmax1.f b/examples/lapack/native/izmax1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/izmax1.f rename to examples/lapack/native/izmax1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/la_constants.f90 b/examples/lapack/native/la_constants.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/la_constants.f90 rename to examples/lapack/native/la_constants.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/la_xisnan.F90 b/examples/lapack/native/la_xisnan.F90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/la_xisnan.F90 rename to examples/lapack/native/la_xisnan.F90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/lsamen.f b/examples/lapack/native/lsamen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/lsamen.f rename to examples/lapack/native/lsamen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbbcsd.f b/examples/lapack/native/sbbcsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbbcsd.f rename to examples/lapack/native/sbbcsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbdsdc.f b/examples/lapack/native/sbdsdc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbdsdc.f rename to examples/lapack/native/sbdsdc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbdsqr.f b/examples/lapack/native/sbdsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbdsqr.f rename to examples/lapack/native/sbdsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbdsvdx.f b/examples/lapack/native/sbdsvdx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sbdsvdx.f rename to examples/lapack/native/sbdsvdx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/scsum1.f b/examples/lapack/native/scsum1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/scsum1.f rename to examples/lapack/native/scsum1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sdisna.f b/examples/lapack/native/sdisna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sdisna.f rename to examples/lapack/native/sdisna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbbrd.f b/examples/lapack/native/sgbbrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbbrd.f rename to examples/lapack/native/sgbbrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbcon.f b/examples/lapack/native/sgbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbcon.f rename to examples/lapack/native/sgbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbequ.f b/examples/lapack/native/sgbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbequ.f rename to examples/lapack/native/sgbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbequb.f b/examples/lapack/native/sgbequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbequb.f rename to examples/lapack/native/sgbequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbrfs.f b/examples/lapack/native/sgbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbrfs.f rename to examples/lapack/native/sgbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbrfsx.f b/examples/lapack/native/sgbrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbrfsx.f rename to examples/lapack/native/sgbrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbsv.f b/examples/lapack/native/sgbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbsv.f rename to examples/lapack/native/sgbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbsvx.f b/examples/lapack/native/sgbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbsvx.f rename to examples/lapack/native/sgbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbsvxx.f b/examples/lapack/native/sgbsvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbsvxx.f rename to examples/lapack/native/sgbsvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbtf2.f b/examples/lapack/native/sgbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbtf2.f rename to examples/lapack/native/sgbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbtrf.f b/examples/lapack/native/sgbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbtrf.f rename to examples/lapack/native/sgbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbtrs.f b/examples/lapack/native/sgbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgbtrs.f rename to examples/lapack/native/sgbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebak.f b/examples/lapack/native/sgebak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebak.f rename to examples/lapack/native/sgebak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebal.f b/examples/lapack/native/sgebal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebal.f rename to examples/lapack/native/sgebal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebd2.f b/examples/lapack/native/sgebd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebd2.f rename to examples/lapack/native/sgebd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebrd.f b/examples/lapack/native/sgebrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgebrd.f rename to examples/lapack/native/sgebrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgecon.f b/examples/lapack/native/sgecon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgecon.f rename to examples/lapack/native/sgecon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgedmd.f90 b/examples/lapack/native/sgedmd.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgedmd.f90 rename to examples/lapack/native/sgedmd.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgedmdq.f90 b/examples/lapack/native/sgedmdq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgedmdq.f90 rename to examples/lapack/native/sgedmdq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeequ.f b/examples/lapack/native/sgeequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeequ.f rename to examples/lapack/native/sgeequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeequb.f b/examples/lapack/native/sgeequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeequb.f rename to examples/lapack/native/sgeequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgees.f b/examples/lapack/native/sgees.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgees.f rename to examples/lapack/native/sgees.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeesx.f b/examples/lapack/native/sgeesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeesx.f rename to examples/lapack/native/sgeesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeev.f b/examples/lapack/native/sgeev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeev.f rename to examples/lapack/native/sgeev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeevx.f b/examples/lapack/native/sgeevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeevx.f rename to examples/lapack/native/sgeevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgehd2.f b/examples/lapack/native/sgehd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgehd2.f rename to examples/lapack/native/sgehd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgehrd.f b/examples/lapack/native/sgehrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgehrd.f rename to examples/lapack/native/sgehrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgejsv.f b/examples/lapack/native/sgejsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgejsv.f rename to examples/lapack/native/sgejsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelq.f b/examples/lapack/native/sgelq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelq.f rename to examples/lapack/native/sgelq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelq2.f b/examples/lapack/native/sgelq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelq2.f rename to examples/lapack/native/sgelq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelqf.f b/examples/lapack/native/sgelqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelqf.f rename to examples/lapack/native/sgelqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelqt.f b/examples/lapack/native/sgelqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelqt.f rename to examples/lapack/native/sgelqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelqt3.f b/examples/lapack/native/sgelqt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelqt3.f rename to examples/lapack/native/sgelqt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgels.f b/examples/lapack/native/sgels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgels.f rename to examples/lapack/native/sgels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelsd.f b/examples/lapack/native/sgelsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelsd.f rename to examples/lapack/native/sgelsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelss.f b/examples/lapack/native/sgelss.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelss.f rename to examples/lapack/native/sgelss.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelst.f b/examples/lapack/native/sgelst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelst.f rename to examples/lapack/native/sgelst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelsy.f b/examples/lapack/native/sgelsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgelsy.f rename to examples/lapack/native/sgelsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemlq.f b/examples/lapack/native/sgemlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemlq.f rename to examples/lapack/native/sgemlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemlqt.f b/examples/lapack/native/sgemlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemlqt.f rename to examples/lapack/native/sgemlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemqr.f b/examples/lapack/native/sgemqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemqr.f rename to examples/lapack/native/sgemqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemqrt.f b/examples/lapack/native/sgemqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgemqrt.f rename to examples/lapack/native/sgemqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeql2.f b/examples/lapack/native/sgeql2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeql2.f rename to examples/lapack/native/sgeql2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqlf.f b/examples/lapack/native/sgeqlf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqlf.f rename to examples/lapack/native/sgeqlf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqp3.f b/examples/lapack/native/sgeqp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqp3.f rename to examples/lapack/native/sgeqp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqp3rk.f b/examples/lapack/native/sgeqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqp3rk.f rename to examples/lapack/native/sgeqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqr.f b/examples/lapack/native/sgeqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqr.f rename to examples/lapack/native/sgeqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqr2.f b/examples/lapack/native/sgeqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqr2.f rename to examples/lapack/native/sgeqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqr2p.f b/examples/lapack/native/sgeqr2p.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqr2p.f rename to examples/lapack/native/sgeqr2p.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrf.f b/examples/lapack/native/sgeqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrf.f rename to examples/lapack/native/sgeqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrfp.f b/examples/lapack/native/sgeqrfp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrfp.f rename to examples/lapack/native/sgeqrfp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrt.f b/examples/lapack/native/sgeqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrt.f rename to examples/lapack/native/sgeqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrt2.f b/examples/lapack/native/sgeqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrt2.f rename to examples/lapack/native/sgeqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrt3.f b/examples/lapack/native/sgeqrt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgeqrt3.f rename to examples/lapack/native/sgeqrt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerfs.f b/examples/lapack/native/sgerfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerfs.f rename to examples/lapack/native/sgerfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerfsx.f b/examples/lapack/native/sgerfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerfsx.f rename to examples/lapack/native/sgerfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerq2.f b/examples/lapack/native/sgerq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerq2.f rename to examples/lapack/native/sgerq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerqf.f b/examples/lapack/native/sgerqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgerqf.f rename to examples/lapack/native/sgerqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesc2.f b/examples/lapack/native/sgesc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesc2.f rename to examples/lapack/native/sgesc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesdd.f b/examples/lapack/native/sgesdd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesdd.f rename to examples/lapack/native/sgesdd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesv.f b/examples/lapack/native/sgesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesv.f rename to examples/lapack/native/sgesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvd.f b/examples/lapack/native/sgesvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvd.f rename to examples/lapack/native/sgesvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvdq.f b/examples/lapack/native/sgesvdq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvdq.f rename to examples/lapack/native/sgesvdq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvdx.f b/examples/lapack/native/sgesvdx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvdx.f rename to examples/lapack/native/sgesvdx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvj.f b/examples/lapack/native/sgesvj.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvj.f rename to examples/lapack/native/sgesvj.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvx.f b/examples/lapack/native/sgesvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvx.f rename to examples/lapack/native/sgesvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvxx.f b/examples/lapack/native/sgesvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgesvxx.f rename to examples/lapack/native/sgesvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetc2.f b/examples/lapack/native/sgetc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetc2.f rename to examples/lapack/native/sgetc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetf2.f b/examples/lapack/native/sgetf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetf2.f rename to examples/lapack/native/sgetf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetrf.f b/examples/lapack/native/sgetrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetrf.f rename to examples/lapack/native/sgetrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetrf2.f b/examples/lapack/native/sgetrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetrf2.f rename to examples/lapack/native/sgetrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetri.f b/examples/lapack/native/sgetri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetri.f rename to examples/lapack/native/sgetri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetrs.f b/examples/lapack/native/sgetrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetrs.f rename to examples/lapack/native/sgetrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetsls.f b/examples/lapack/native/sgetsls.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetsls.f rename to examples/lapack/native/sgetsls.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetsqrhrt.f b/examples/lapack/native/sgetsqrhrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgetsqrhrt.f rename to examples/lapack/native/sgetsqrhrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggbak.f b/examples/lapack/native/sggbak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggbak.f rename to examples/lapack/native/sggbak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggbal.f b/examples/lapack/native/sggbal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggbal.f rename to examples/lapack/native/sggbal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgges.f b/examples/lapack/native/sgges.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgges.f rename to examples/lapack/native/sgges.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgges3.f b/examples/lapack/native/sgges3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgges3.f rename to examples/lapack/native/sgges3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggesx.f b/examples/lapack/native/sggesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggesx.f rename to examples/lapack/native/sggesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggev.f b/examples/lapack/native/sggev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggev.f rename to examples/lapack/native/sggev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggev3.f b/examples/lapack/native/sggev3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggev3.f rename to examples/lapack/native/sggev3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggevx.f b/examples/lapack/native/sggevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggevx.f rename to examples/lapack/native/sggevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggglm.f b/examples/lapack/native/sggglm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggglm.f rename to examples/lapack/native/sggglm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgghd3.f b/examples/lapack/native/sgghd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgghd3.f rename to examples/lapack/native/sgghd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgghrd.f b/examples/lapack/native/sgghrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgghrd.f rename to examples/lapack/native/sgghrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgglse.f b/examples/lapack/native/sgglse.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgglse.f rename to examples/lapack/native/sgglse.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggqrf.f b/examples/lapack/native/sggqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggqrf.f rename to examples/lapack/native/sggqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggrqf.f b/examples/lapack/native/sggrqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggrqf.f rename to examples/lapack/native/sggrqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggsvd3.f b/examples/lapack/native/sggsvd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggsvd3.f rename to examples/lapack/native/sggsvd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggsvp3.f b/examples/lapack/native/sggsvp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sggsvp3.f rename to examples/lapack/native/sggsvp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgsvj0.f b/examples/lapack/native/sgsvj0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgsvj0.f rename to examples/lapack/native/sgsvj0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgsvj1.f b/examples/lapack/native/sgsvj1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgsvj1.f rename to examples/lapack/native/sgsvj1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtcon.f b/examples/lapack/native/sgtcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtcon.f rename to examples/lapack/native/sgtcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtrfs.f b/examples/lapack/native/sgtrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtrfs.f rename to examples/lapack/native/sgtrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtsv.f b/examples/lapack/native/sgtsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtsv.f rename to examples/lapack/native/sgtsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtsvx.f b/examples/lapack/native/sgtsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtsvx.f rename to examples/lapack/native/sgtsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgttrf.f b/examples/lapack/native/sgttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgttrf.f rename to examples/lapack/native/sgttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgttrs.f b/examples/lapack/native/sgttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgttrs.f rename to examples/lapack/native/sgttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtts2.f b/examples/lapack/native/sgtts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sgtts2.f rename to examples/lapack/native/sgtts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/shgeqz.f b/examples/lapack/native/shgeqz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/shgeqz.f rename to examples/lapack/native/shgeqz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/shsein.f b/examples/lapack/native/shsein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/shsein.f rename to examples/lapack/native/shsein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/shseqr.f b/examples/lapack/native/shseqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/shseqr.f rename to examples/lapack/native/shseqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sisnan.f b/examples/lapack/native/sisnan.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sisnan.f rename to examples/lapack/native/sisnan.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbamv.f b/examples/lapack/native/sla_gbamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbamv.f rename to examples/lapack/native/sla_gbamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbrcond.f b/examples/lapack/native/sla_gbrcond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbrcond.f rename to examples/lapack/native/sla_gbrcond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbrfsx_extended.f b/examples/lapack/native/sla_gbrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbrfsx_extended.f rename to examples/lapack/native/sla_gbrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbrpvgrw.f b/examples/lapack/native/sla_gbrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gbrpvgrw.f rename to examples/lapack/native/sla_gbrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_geamv.f b/examples/lapack/native/sla_geamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_geamv.f rename to examples/lapack/native/sla_geamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gercond.f b/examples/lapack/native/sla_gercond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gercond.f rename to examples/lapack/native/sla_gercond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gerfsx_extended.f b/examples/lapack/native/sla_gerfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gerfsx_extended.f rename to examples/lapack/native/sla_gerfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gerpvgrw.f b/examples/lapack/native/sla_gerpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_gerpvgrw.f rename to examples/lapack/native/sla_gerpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_lin_berr.f b/examples/lapack/native/sla_lin_berr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_lin_berr.f rename to examples/lapack/native/sla_lin_berr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_porcond.f b/examples/lapack/native/sla_porcond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_porcond.f rename to examples/lapack/native/sla_porcond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_porfsx_extended.f b/examples/lapack/native/sla_porfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_porfsx_extended.f rename to examples/lapack/native/sla_porfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_porpvgrw.f b/examples/lapack/native/sla_porpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_porpvgrw.f rename to examples/lapack/native/sla_porpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syamv.f b/examples/lapack/native/sla_syamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syamv.f rename to examples/lapack/native/sla_syamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syrcond.f b/examples/lapack/native/sla_syrcond.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syrcond.f rename to examples/lapack/native/sla_syrcond.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syrfsx_extended.f b/examples/lapack/native/sla_syrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syrfsx_extended.f rename to examples/lapack/native/sla_syrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syrpvgrw.f b/examples/lapack/native/sla_syrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_syrpvgrw.f rename to examples/lapack/native/sla_syrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_wwaddw.f b/examples/lapack/native/sla_wwaddw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sla_wwaddw.f rename to examples/lapack/native/sla_wwaddw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slabad.f b/examples/lapack/native/slabad.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slabad.f rename to examples/lapack/native/slabad.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slabrd.f b/examples/lapack/native/slabrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slabrd.f rename to examples/lapack/native/slabrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slacn2.f b/examples/lapack/native/slacn2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slacn2.f rename to examples/lapack/native/slacn2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slacon.f b/examples/lapack/native/slacon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slacon.f rename to examples/lapack/native/slacon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slacpy.f b/examples/lapack/native/slacpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slacpy.f rename to examples/lapack/native/slacpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sladiv.f b/examples/lapack/native/sladiv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sladiv.f rename to examples/lapack/native/sladiv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slae2.f b/examples/lapack/native/slae2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slae2.f rename to examples/lapack/native/slae2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaebz.f b/examples/lapack/native/slaebz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaebz.f rename to examples/lapack/native/slaebz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed0.f b/examples/lapack/native/slaed0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed0.f rename to examples/lapack/native/slaed0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed1.f b/examples/lapack/native/slaed1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed1.f rename to examples/lapack/native/slaed1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed2.f b/examples/lapack/native/slaed2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed2.f rename to examples/lapack/native/slaed2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed3.f b/examples/lapack/native/slaed3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed3.f rename to examples/lapack/native/slaed3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed4.f b/examples/lapack/native/slaed4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed4.f rename to examples/lapack/native/slaed4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed5.f b/examples/lapack/native/slaed5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed5.f rename to examples/lapack/native/slaed5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed6.f b/examples/lapack/native/slaed6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed6.f rename to examples/lapack/native/slaed6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed7.f b/examples/lapack/native/slaed7.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed7.f rename to examples/lapack/native/slaed7.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed8.f b/examples/lapack/native/slaed8.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed8.f rename to examples/lapack/native/slaed8.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed9.f b/examples/lapack/native/slaed9.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaed9.f rename to examples/lapack/native/slaed9.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaeda.f b/examples/lapack/native/slaeda.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaeda.f rename to examples/lapack/native/slaeda.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaein.f b/examples/lapack/native/slaein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaein.f rename to examples/lapack/native/slaein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaev2.f b/examples/lapack/native/slaev2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaev2.f rename to examples/lapack/native/slaev2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaexc.f b/examples/lapack/native/slaexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaexc.f rename to examples/lapack/native/slaexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slag2.f b/examples/lapack/native/slag2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slag2.f rename to examples/lapack/native/slag2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slag2d.f b/examples/lapack/native/slag2d.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slag2d.f rename to examples/lapack/native/slag2d.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slags2.f b/examples/lapack/native/slags2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slags2.f rename to examples/lapack/native/slags2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagtf.f b/examples/lapack/native/slagtf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagtf.f rename to examples/lapack/native/slagtf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagtm.f b/examples/lapack/native/slagtm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagtm.f rename to examples/lapack/native/slagtm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagts.f b/examples/lapack/native/slagts.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagts.f rename to examples/lapack/native/slagts.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagv2.f b/examples/lapack/native/slagv2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slagv2.f rename to examples/lapack/native/slagv2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slahqr.f b/examples/lapack/native/slahqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slahqr.f rename to examples/lapack/native/slahqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slahr2.f b/examples/lapack/native/slahr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slahr2.f rename to examples/lapack/native/slahr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaic1.f b/examples/lapack/native/slaic1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaic1.f rename to examples/lapack/native/slaic1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaisnan.f b/examples/lapack/native/slaisnan.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaisnan.f rename to examples/lapack/native/slaisnan.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaln2.f b/examples/lapack/native/slaln2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaln2.f rename to examples/lapack/native/slaln2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slals0.f b/examples/lapack/native/slals0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slals0.f rename to examples/lapack/native/slals0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slalsa.f b/examples/lapack/native/slalsa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slalsa.f rename to examples/lapack/native/slalsa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slalsd.f b/examples/lapack/native/slalsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slalsd.f rename to examples/lapack/native/slalsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slamrg.f b/examples/lapack/native/slamrg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slamrg.f rename to examples/lapack/native/slamrg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slamswlq.f b/examples/lapack/native/slamswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slamswlq.f rename to examples/lapack/native/slamswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slamtsqr.f b/examples/lapack/native/slamtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slamtsqr.f rename to examples/lapack/native/slamtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaneg.f b/examples/lapack/native/slaneg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaneg.f rename to examples/lapack/native/slaneg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slangb.f b/examples/lapack/native/slangb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slangb.f rename to examples/lapack/native/slangb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slange.f b/examples/lapack/native/slange.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slange.f rename to examples/lapack/native/slange.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slangt.f b/examples/lapack/native/slangt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slangt.f rename to examples/lapack/native/slangt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slanhs.f b/examples/lapack/native/slanhs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slanhs.f rename to examples/lapack/native/slanhs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansb.f b/examples/lapack/native/slansb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansb.f rename to examples/lapack/native/slansb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansf.f b/examples/lapack/native/slansf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansf.f rename to examples/lapack/native/slansf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansp.f b/examples/lapack/native/slansp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansp.f rename to examples/lapack/native/slansp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slanst.f b/examples/lapack/native/slanst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slanst.f rename to examples/lapack/native/slanst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansy.f b/examples/lapack/native/slansy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slansy.f rename to examples/lapack/native/slansy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slantb.f b/examples/lapack/native/slantb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slantb.f rename to examples/lapack/native/slantb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slantp.f b/examples/lapack/native/slantp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slantp.f rename to examples/lapack/native/slantp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slantr.f b/examples/lapack/native/slantr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slantr.f rename to examples/lapack/native/slantr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slanv2.f b/examples/lapack/native/slanv2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slanv2.f rename to examples/lapack/native/slanv2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaorhr_col_getrfnp.f b/examples/lapack/native/slaorhr_col_getrfnp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaorhr_col_getrfnp.f rename to examples/lapack/native/slaorhr_col_getrfnp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaorhr_col_getrfnp2.f b/examples/lapack/native/slaorhr_col_getrfnp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaorhr_col_getrfnp2.f rename to examples/lapack/native/slaorhr_col_getrfnp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapll.f b/examples/lapack/native/slapll.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapll.f rename to examples/lapack/native/slapll.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapmr.f b/examples/lapack/native/slapmr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapmr.f rename to examples/lapack/native/slapmr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapmt.f b/examples/lapack/native/slapmt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapmt.f rename to examples/lapack/native/slapmt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapy2.f b/examples/lapack/native/slapy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapy2.f rename to examples/lapack/native/slapy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapy3.f b/examples/lapack/native/slapy3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slapy3.f rename to examples/lapack/native/slapy3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqgb.f b/examples/lapack/native/slaqgb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqgb.f rename to examples/lapack/native/slaqgb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqge.f b/examples/lapack/native/slaqge.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqge.f rename to examples/lapack/native/slaqge.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqp2.f b/examples/lapack/native/slaqp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqp2.f rename to examples/lapack/native/slaqp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqp2rk.f b/examples/lapack/native/slaqp2rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqp2rk.f rename to examples/lapack/native/slaqp2rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqp3rk.f b/examples/lapack/native/slaqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqp3rk.f rename to examples/lapack/native/slaqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqps.f b/examples/lapack/native/slaqps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqps.f rename to examples/lapack/native/slaqps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr0.f b/examples/lapack/native/slaqr0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr0.f rename to examples/lapack/native/slaqr0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr1.f b/examples/lapack/native/slaqr1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr1.f rename to examples/lapack/native/slaqr1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr2.f b/examples/lapack/native/slaqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr2.f rename to examples/lapack/native/slaqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr3.f b/examples/lapack/native/slaqr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr3.f rename to examples/lapack/native/slaqr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr4.f b/examples/lapack/native/slaqr4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr4.f rename to examples/lapack/native/slaqr4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr5.f b/examples/lapack/native/slaqr5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqr5.f rename to examples/lapack/native/slaqr5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqsb.f b/examples/lapack/native/slaqsb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqsb.f rename to examples/lapack/native/slaqsb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqsp.f b/examples/lapack/native/slaqsp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqsp.f rename to examples/lapack/native/slaqsp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqsy.f b/examples/lapack/native/slaqsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqsy.f rename to examples/lapack/native/slaqsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqtr.f b/examples/lapack/native/slaqtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqtr.f rename to examples/lapack/native/slaqtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz0.f b/examples/lapack/native/slaqz0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz0.f rename to examples/lapack/native/slaqz0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz1.f b/examples/lapack/native/slaqz1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz1.f rename to examples/lapack/native/slaqz1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz2.f b/examples/lapack/native/slaqz2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz2.f rename to examples/lapack/native/slaqz2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz3.f b/examples/lapack/native/slaqz3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz3.f rename to examples/lapack/native/slaqz3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz4.f b/examples/lapack/native/slaqz4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaqz4.f rename to examples/lapack/native/slaqz4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slar1v.f b/examples/lapack/native/slar1v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slar1v.f rename to examples/lapack/native/slar1v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slar2v.f b/examples/lapack/native/slar2v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slar2v.f rename to examples/lapack/native/slar2v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarf.f b/examples/lapack/native/slarf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarf.f rename to examples/lapack/native/slarf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarf1f.f b/examples/lapack/native/slarf1f.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarf1f.f rename to examples/lapack/native/slarf1f.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarf1l.f b/examples/lapack/native/slarf1l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarf1l.f rename to examples/lapack/native/slarf1l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfb.f b/examples/lapack/native/slarfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfb.f rename to examples/lapack/native/slarfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfb_gett.f b/examples/lapack/native/slarfb_gett.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfb_gett.f rename to examples/lapack/native/slarfb_gett.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfg.f b/examples/lapack/native/slarfg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfg.f rename to examples/lapack/native/slarfg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfgp.f b/examples/lapack/native/slarfgp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfgp.f rename to examples/lapack/native/slarfgp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarft.f b/examples/lapack/native/slarft.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarft.f rename to examples/lapack/native/slarft.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfx.f b/examples/lapack/native/slarfx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfx.f rename to examples/lapack/native/slarfx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfy.f b/examples/lapack/native/slarfy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarfy.f rename to examples/lapack/native/slarfy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slargv.f b/examples/lapack/native/slargv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slargv.f rename to examples/lapack/native/slargv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarmm.f b/examples/lapack/native/slarmm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarmm.f rename to examples/lapack/native/slarmm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarnv.f b/examples/lapack/native/slarnv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarnv.f rename to examples/lapack/native/slarnv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarra.f b/examples/lapack/native/slarra.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarra.f rename to examples/lapack/native/slarra.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrb.f b/examples/lapack/native/slarrb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrb.f rename to examples/lapack/native/slarrb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrc.f b/examples/lapack/native/slarrc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrc.f rename to examples/lapack/native/slarrc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrd.f b/examples/lapack/native/slarrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrd.f rename to examples/lapack/native/slarrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarre.f b/examples/lapack/native/slarre.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarre.f rename to examples/lapack/native/slarre.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrf.f b/examples/lapack/native/slarrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrf.f rename to examples/lapack/native/slarrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrj.f b/examples/lapack/native/slarrj.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrj.f rename to examples/lapack/native/slarrj.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrk.f b/examples/lapack/native/slarrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrk.f rename to examples/lapack/native/slarrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrr.f b/examples/lapack/native/slarrr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrr.f rename to examples/lapack/native/slarrr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrv.f b/examples/lapack/native/slarrv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarrv.f rename to examples/lapack/native/slarrv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarscl2.f b/examples/lapack/native/slarscl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarscl2.f rename to examples/lapack/native/slarscl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartg.f90 b/examples/lapack/native/slartg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartg.f90 rename to examples/lapack/native/slartg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartgp.f b/examples/lapack/native/slartgp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartgp.f rename to examples/lapack/native/slartgp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartgs.f b/examples/lapack/native/slartgs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartgs.f rename to examples/lapack/native/slartgs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartv.f b/examples/lapack/native/slartv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slartv.f rename to examples/lapack/native/slartv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaruv.f b/examples/lapack/native/slaruv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaruv.f rename to examples/lapack/native/slaruv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarz.f b/examples/lapack/native/slarz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarz.f rename to examples/lapack/native/slarz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarzb.f b/examples/lapack/native/slarzb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarzb.f rename to examples/lapack/native/slarzb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarzt.f b/examples/lapack/native/slarzt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slarzt.f rename to examples/lapack/native/slarzt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slas2.f b/examples/lapack/native/slas2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slas2.f rename to examples/lapack/native/slas2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slascl.f b/examples/lapack/native/slascl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slascl.f rename to examples/lapack/native/slascl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slascl2.f b/examples/lapack/native/slascl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slascl2.f rename to examples/lapack/native/slascl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd0.f b/examples/lapack/native/slasd0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd0.f rename to examples/lapack/native/slasd0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd1.f b/examples/lapack/native/slasd1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd1.f rename to examples/lapack/native/slasd1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd2.f b/examples/lapack/native/slasd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd2.f rename to examples/lapack/native/slasd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd3.f b/examples/lapack/native/slasd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd3.f rename to examples/lapack/native/slasd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd4.f b/examples/lapack/native/slasd4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd4.f rename to examples/lapack/native/slasd4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd5.f b/examples/lapack/native/slasd5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd5.f rename to examples/lapack/native/slasd5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd6.f b/examples/lapack/native/slasd6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd6.f rename to examples/lapack/native/slasd6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd7.f b/examples/lapack/native/slasd7.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd7.f rename to examples/lapack/native/slasd7.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd8.f b/examples/lapack/native/slasd8.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasd8.f rename to examples/lapack/native/slasd8.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasda.f b/examples/lapack/native/slasda.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasda.f rename to examples/lapack/native/slasda.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasdq.f b/examples/lapack/native/slasdq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasdq.f rename to examples/lapack/native/slasdq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasdt.f b/examples/lapack/native/slasdt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasdt.f rename to examples/lapack/native/slasdt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaset.f b/examples/lapack/native/slaset.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaset.f rename to examples/lapack/native/slaset.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq1.f b/examples/lapack/native/slasq1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq1.f rename to examples/lapack/native/slasq1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq2.f b/examples/lapack/native/slasq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq2.f rename to examples/lapack/native/slasq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq3.f b/examples/lapack/native/slasq3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq3.f rename to examples/lapack/native/slasq3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq4.f b/examples/lapack/native/slasq4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq4.f rename to examples/lapack/native/slasq4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq5.f b/examples/lapack/native/slasq5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq5.f rename to examples/lapack/native/slasq5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq6.f b/examples/lapack/native/slasq6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasq6.f rename to examples/lapack/native/slasq6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasr.f b/examples/lapack/native/slasr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasr.f rename to examples/lapack/native/slasr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasrt.f b/examples/lapack/native/slasrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasrt.f rename to examples/lapack/native/slasrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slassq.f90 b/examples/lapack/native/slassq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slassq.f90 rename to examples/lapack/native/slassq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasv2.f b/examples/lapack/native/slasv2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasv2.f rename to examples/lapack/native/slasv2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaswlq.f b/examples/lapack/native/slaswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaswlq.f rename to examples/lapack/native/slaswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaswp.f b/examples/lapack/native/slaswp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slaswp.f rename to examples/lapack/native/slaswp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasy2.f b/examples/lapack/native/slasy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasy2.f rename to examples/lapack/native/slasy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf.f b/examples/lapack/native/slasyf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf.f rename to examples/lapack/native/slasyf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf_aa.f b/examples/lapack/native/slasyf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf_aa.f rename to examples/lapack/native/slasyf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf_rk.f b/examples/lapack/native/slasyf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf_rk.f rename to examples/lapack/native/slasyf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf_rook.f b/examples/lapack/native/slasyf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slasyf_rook.f rename to examples/lapack/native/slasyf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatbs.f b/examples/lapack/native/slatbs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatbs.f rename to examples/lapack/native/slatbs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatdf.f b/examples/lapack/native/slatdf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatdf.f rename to examples/lapack/native/slatdf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatps.f b/examples/lapack/native/slatps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatps.f rename to examples/lapack/native/slatps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrd.f b/examples/lapack/native/slatrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrd.f rename to examples/lapack/native/slatrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrs.f b/examples/lapack/native/slatrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrs.f rename to examples/lapack/native/slatrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrs3.f b/examples/lapack/native/slatrs3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrs3.f rename to examples/lapack/native/slatrs3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrz.f b/examples/lapack/native/slatrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatrz.f rename to examples/lapack/native/slatrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatsqr.f b/examples/lapack/native/slatsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slatsqr.f rename to examples/lapack/native/slatsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slauu2.f b/examples/lapack/native/slauu2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slauu2.f rename to examples/lapack/native/slauu2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slauum.f b/examples/lapack/native/slauum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/slauum.f rename to examples/lapack/native/slauum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sopgtr.f b/examples/lapack/native/sopgtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sopgtr.f rename to examples/lapack/native/sopgtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sopmtr.f b/examples/lapack/native/sopmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sopmtr.f rename to examples/lapack/native/sopmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb.f b/examples/lapack/native/sorbdb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb.f rename to examples/lapack/native/sorbdb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb1.f b/examples/lapack/native/sorbdb1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb1.f rename to examples/lapack/native/sorbdb1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb2.f b/examples/lapack/native/sorbdb2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb2.f rename to examples/lapack/native/sorbdb2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb3.f b/examples/lapack/native/sorbdb3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb3.f rename to examples/lapack/native/sorbdb3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb4.f b/examples/lapack/native/sorbdb4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb4.f rename to examples/lapack/native/sorbdb4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb5.f b/examples/lapack/native/sorbdb5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb5.f rename to examples/lapack/native/sorbdb5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb6.f b/examples/lapack/native/sorbdb6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorbdb6.f rename to examples/lapack/native/sorbdb6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorcsd.f b/examples/lapack/native/sorcsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorcsd.f rename to examples/lapack/native/sorcsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorcsd2by1.f b/examples/lapack/native/sorcsd2by1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorcsd2by1.f rename to examples/lapack/native/sorcsd2by1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorg2l.f b/examples/lapack/native/sorg2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorg2l.f rename to examples/lapack/native/sorg2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorg2r.f b/examples/lapack/native/sorg2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorg2r.f rename to examples/lapack/native/sorg2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgbr.f b/examples/lapack/native/sorgbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgbr.f rename to examples/lapack/native/sorgbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorghr.f b/examples/lapack/native/sorghr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorghr.f rename to examples/lapack/native/sorghr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgl2.f b/examples/lapack/native/sorgl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgl2.f rename to examples/lapack/native/sorgl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorglq.f b/examples/lapack/native/sorglq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorglq.f rename to examples/lapack/native/sorglq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgql.f b/examples/lapack/native/sorgql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgql.f rename to examples/lapack/native/sorgql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgqr.f b/examples/lapack/native/sorgqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgqr.f rename to examples/lapack/native/sorgqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgr2.f b/examples/lapack/native/sorgr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgr2.f rename to examples/lapack/native/sorgr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgrq.f b/examples/lapack/native/sorgrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgrq.f rename to examples/lapack/native/sorgrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgtr.f b/examples/lapack/native/sorgtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgtr.f rename to examples/lapack/native/sorgtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgtsqr.f b/examples/lapack/native/sorgtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgtsqr.f rename to examples/lapack/native/sorgtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgtsqr_row.f b/examples/lapack/native/sorgtsqr_row.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorgtsqr_row.f rename to examples/lapack/native/sorgtsqr_row.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorhr_col.f b/examples/lapack/native/sorhr_col.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorhr_col.f rename to examples/lapack/native/sorhr_col.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorm22.f b/examples/lapack/native/sorm22.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorm22.f rename to examples/lapack/native/sorm22.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorm2l.f b/examples/lapack/native/sorm2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorm2l.f rename to examples/lapack/native/sorm2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorm2r.f b/examples/lapack/native/sorm2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorm2r.f rename to examples/lapack/native/sorm2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormbr.f b/examples/lapack/native/sormbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormbr.f rename to examples/lapack/native/sormbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormhr.f b/examples/lapack/native/sormhr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormhr.f rename to examples/lapack/native/sormhr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorml2.f b/examples/lapack/native/sorml2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sorml2.f rename to examples/lapack/native/sorml2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormlq.f b/examples/lapack/native/sormlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormlq.f rename to examples/lapack/native/sormlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormql.f b/examples/lapack/native/sormql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormql.f rename to examples/lapack/native/sormql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormqr.f b/examples/lapack/native/sormqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormqr.f rename to examples/lapack/native/sormqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormr2.f b/examples/lapack/native/sormr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormr2.f rename to examples/lapack/native/sormr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormr3.f b/examples/lapack/native/sormr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormr3.f rename to examples/lapack/native/sormr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormrq.f b/examples/lapack/native/sormrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormrq.f rename to examples/lapack/native/sormrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormrz.f b/examples/lapack/native/sormrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormrz.f rename to examples/lapack/native/sormrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormtr.f b/examples/lapack/native/sormtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sormtr.f rename to examples/lapack/native/sormtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbcon.f b/examples/lapack/native/spbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbcon.f rename to examples/lapack/native/spbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbequ.f b/examples/lapack/native/spbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbequ.f rename to examples/lapack/native/spbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbrfs.f b/examples/lapack/native/spbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbrfs.f rename to examples/lapack/native/spbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbstf.f b/examples/lapack/native/spbstf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbstf.f rename to examples/lapack/native/spbstf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbsv.f b/examples/lapack/native/spbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbsv.f rename to examples/lapack/native/spbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbsvx.f b/examples/lapack/native/spbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbsvx.f rename to examples/lapack/native/spbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbtf2.f b/examples/lapack/native/spbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbtf2.f rename to examples/lapack/native/spbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbtrf.f b/examples/lapack/native/spbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbtrf.f rename to examples/lapack/native/spbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbtrs.f b/examples/lapack/native/spbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spbtrs.f rename to examples/lapack/native/spbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spftrf.f b/examples/lapack/native/spftrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spftrf.f rename to examples/lapack/native/spftrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spftri.f b/examples/lapack/native/spftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spftri.f rename to examples/lapack/native/spftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spftrs.f b/examples/lapack/native/spftrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spftrs.f rename to examples/lapack/native/spftrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spocon.f b/examples/lapack/native/spocon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spocon.f rename to examples/lapack/native/spocon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spoequ.f b/examples/lapack/native/spoequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spoequ.f rename to examples/lapack/native/spoequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spoequb.f b/examples/lapack/native/spoequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spoequb.f rename to examples/lapack/native/spoequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sporfs.f b/examples/lapack/native/sporfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sporfs.f rename to examples/lapack/native/sporfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sporfsx.f b/examples/lapack/native/sporfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sporfsx.f rename to examples/lapack/native/sporfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sposv.f b/examples/lapack/native/sposv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sposv.f rename to examples/lapack/native/sposv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sposvx.f b/examples/lapack/native/sposvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sposvx.f rename to examples/lapack/native/sposvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sposvxx.f b/examples/lapack/native/sposvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sposvxx.f rename to examples/lapack/native/sposvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotf2.f b/examples/lapack/native/spotf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotf2.f rename to examples/lapack/native/spotf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotrf.f b/examples/lapack/native/spotrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotrf.f rename to examples/lapack/native/spotrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotrf2.f b/examples/lapack/native/spotrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotrf2.f rename to examples/lapack/native/spotrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotri.f b/examples/lapack/native/spotri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotri.f rename to examples/lapack/native/spotri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotrs.f b/examples/lapack/native/spotrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spotrs.f rename to examples/lapack/native/spotrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppcon.f b/examples/lapack/native/sppcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppcon.f rename to examples/lapack/native/sppcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppequ.f b/examples/lapack/native/sppequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppequ.f rename to examples/lapack/native/sppequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spprfs.f b/examples/lapack/native/spprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spprfs.f rename to examples/lapack/native/spprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppsv.f b/examples/lapack/native/sppsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppsv.f rename to examples/lapack/native/sppsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppsvx.f b/examples/lapack/native/sppsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sppsvx.f rename to examples/lapack/native/sppsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spptrf.f b/examples/lapack/native/spptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spptrf.f rename to examples/lapack/native/spptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spptri.f b/examples/lapack/native/spptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spptri.f rename to examples/lapack/native/spptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spptrs.f b/examples/lapack/native/spptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spptrs.f rename to examples/lapack/native/spptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spstf2.f b/examples/lapack/native/spstf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spstf2.f rename to examples/lapack/native/spstf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spstrf.f b/examples/lapack/native/spstrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spstrf.f rename to examples/lapack/native/spstrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptcon.f b/examples/lapack/native/sptcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptcon.f rename to examples/lapack/native/sptcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spteqr.f b/examples/lapack/native/spteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spteqr.f rename to examples/lapack/native/spteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptrfs.f b/examples/lapack/native/sptrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptrfs.f rename to examples/lapack/native/sptrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptsv.f b/examples/lapack/native/sptsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptsv.f rename to examples/lapack/native/sptsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptsvx.f b/examples/lapack/native/sptsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptsvx.f rename to examples/lapack/native/sptsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spttrf.f b/examples/lapack/native/spttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spttrf.f rename to examples/lapack/native/spttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spttrs.f b/examples/lapack/native/spttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/spttrs.f rename to examples/lapack/native/spttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptts2.f b/examples/lapack/native/sptts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sptts2.f rename to examples/lapack/native/sptts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/srscl.f b/examples/lapack/native/srscl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/srscl.f rename to examples/lapack/native/srscl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssb2st_kernels.f b/examples/lapack/native/ssb2st_kernels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssb2st_kernels.f rename to examples/lapack/native/ssb2st_kernels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbev.f b/examples/lapack/native/ssbev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbev.f rename to examples/lapack/native/ssbev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbev_2stage.f b/examples/lapack/native/ssbev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbev_2stage.f rename to examples/lapack/native/ssbev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevd.f b/examples/lapack/native/ssbevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevd.f rename to examples/lapack/native/ssbevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevd_2stage.f b/examples/lapack/native/ssbevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevd_2stage.f rename to examples/lapack/native/ssbevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevx.f b/examples/lapack/native/ssbevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevx.f rename to examples/lapack/native/ssbevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevx_2stage.f b/examples/lapack/native/ssbevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbevx_2stage.f rename to examples/lapack/native/ssbevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgst.f b/examples/lapack/native/ssbgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgst.f rename to examples/lapack/native/ssbgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgv.f b/examples/lapack/native/ssbgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgv.f rename to examples/lapack/native/ssbgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgvd.f b/examples/lapack/native/ssbgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgvd.f rename to examples/lapack/native/ssbgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgvx.f b/examples/lapack/native/ssbgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbgvx.f rename to examples/lapack/native/ssbgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbtrd.f b/examples/lapack/native/ssbtrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssbtrd.f rename to examples/lapack/native/ssbtrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssfrk.f b/examples/lapack/native/ssfrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssfrk.f rename to examples/lapack/native/ssfrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspcon.f b/examples/lapack/native/sspcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspcon.f rename to examples/lapack/native/sspcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspev.f b/examples/lapack/native/sspev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspev.f rename to examples/lapack/native/sspev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspevd.f b/examples/lapack/native/sspevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspevd.f rename to examples/lapack/native/sspevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspevx.f b/examples/lapack/native/sspevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspevx.f rename to examples/lapack/native/sspevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgst.f b/examples/lapack/native/sspgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgst.f rename to examples/lapack/native/sspgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgv.f b/examples/lapack/native/sspgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgv.f rename to examples/lapack/native/sspgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgvd.f b/examples/lapack/native/sspgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgvd.f rename to examples/lapack/native/sspgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgvx.f b/examples/lapack/native/sspgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspgvx.f rename to examples/lapack/native/sspgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssprfs.f b/examples/lapack/native/ssprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssprfs.f rename to examples/lapack/native/ssprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspsv.f b/examples/lapack/native/sspsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspsv.f rename to examples/lapack/native/sspsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspsvx.f b/examples/lapack/native/sspsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sspsvx.f rename to examples/lapack/native/sspsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptrd.f b/examples/lapack/native/ssptrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptrd.f rename to examples/lapack/native/ssptrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptrf.f b/examples/lapack/native/ssptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptrf.f rename to examples/lapack/native/ssptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptri.f b/examples/lapack/native/ssptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptri.f rename to examples/lapack/native/ssptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptrs.f b/examples/lapack/native/ssptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssptrs.f rename to examples/lapack/native/ssptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstebz.f b/examples/lapack/native/sstebz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstebz.f rename to examples/lapack/native/sstebz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstedc.f b/examples/lapack/native/sstedc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstedc.f rename to examples/lapack/native/sstedc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstegr.f b/examples/lapack/native/sstegr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstegr.f rename to examples/lapack/native/sstegr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstein.f b/examples/lapack/native/sstein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstein.f rename to examples/lapack/native/sstein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstemr.f b/examples/lapack/native/sstemr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstemr.f rename to examples/lapack/native/sstemr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssteqr.f b/examples/lapack/native/ssteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssteqr.f rename to examples/lapack/native/ssteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssterf.f b/examples/lapack/native/ssterf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssterf.f rename to examples/lapack/native/ssterf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstev.f b/examples/lapack/native/sstev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstev.f rename to examples/lapack/native/sstev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstevd.f b/examples/lapack/native/sstevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstevd.f rename to examples/lapack/native/sstevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstevr.f b/examples/lapack/native/sstevr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstevr.f rename to examples/lapack/native/sstevr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstevx.f b/examples/lapack/native/sstevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/sstevx.f rename to examples/lapack/native/sstevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssycon.f b/examples/lapack/native/ssycon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssycon.f rename to examples/lapack/native/ssycon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssycon_3.f b/examples/lapack/native/ssycon_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssycon_3.f rename to examples/lapack/native/ssycon_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssycon_rook.f b/examples/lapack/native/ssycon_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssycon_rook.f rename to examples/lapack/native/ssycon_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyconv.f b/examples/lapack/native/ssyconv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyconv.f rename to examples/lapack/native/ssyconv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyconvf.f b/examples/lapack/native/ssyconvf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyconvf.f rename to examples/lapack/native/ssyconvf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyconvf_rook.f b/examples/lapack/native/ssyconvf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyconvf_rook.f rename to examples/lapack/native/ssyconvf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyequb.f b/examples/lapack/native/ssyequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyequb.f rename to examples/lapack/native/ssyequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyev.f b/examples/lapack/native/ssyev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyev.f rename to examples/lapack/native/ssyev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyev_2stage.f b/examples/lapack/native/ssyev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyev_2stage.f rename to examples/lapack/native/ssyev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevd.f b/examples/lapack/native/ssyevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevd.f rename to examples/lapack/native/ssyevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevd_2stage.f b/examples/lapack/native/ssyevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevd_2stage.f rename to examples/lapack/native/ssyevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevr.f b/examples/lapack/native/ssyevr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevr.f rename to examples/lapack/native/ssyevr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevr_2stage.f b/examples/lapack/native/ssyevr_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevr_2stage.f rename to examples/lapack/native/ssyevr_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevx.f b/examples/lapack/native/ssyevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevx.f rename to examples/lapack/native/ssyevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevx_2stage.f b/examples/lapack/native/ssyevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyevx_2stage.f rename to examples/lapack/native/ssyevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygs2.f b/examples/lapack/native/ssygs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygs2.f rename to examples/lapack/native/ssygs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygst.f b/examples/lapack/native/ssygst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygst.f rename to examples/lapack/native/ssygst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygv.f b/examples/lapack/native/ssygv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygv.f rename to examples/lapack/native/ssygv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygv_2stage.f b/examples/lapack/native/ssygv_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygv_2stage.f rename to examples/lapack/native/ssygv_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygvd.f b/examples/lapack/native/ssygvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygvd.f rename to examples/lapack/native/ssygvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygvx.f b/examples/lapack/native/ssygvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssygvx.f rename to examples/lapack/native/ssygvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyrfs.f b/examples/lapack/native/ssyrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyrfs.f rename to examples/lapack/native/ssyrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyrfsx.f b/examples/lapack/native/ssyrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyrfsx.f rename to examples/lapack/native/ssyrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv.f b/examples/lapack/native/ssysv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv.f rename to examples/lapack/native/ssysv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_aa.f b/examples/lapack/native/ssysv_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_aa.f rename to examples/lapack/native/ssysv_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_aa_2stage.f b/examples/lapack/native/ssysv_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_aa_2stage.f rename to examples/lapack/native/ssysv_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_rk.f b/examples/lapack/native/ssysv_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_rk.f rename to examples/lapack/native/ssysv_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_rook.f b/examples/lapack/native/ssysv_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysv_rook.f rename to examples/lapack/native/ssysv_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysvx.f b/examples/lapack/native/ssysvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysvx.f rename to examples/lapack/native/ssysvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysvxx.f b/examples/lapack/native/ssysvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssysvxx.f rename to examples/lapack/native/ssysvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyswapr.f b/examples/lapack/native/ssyswapr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssyswapr.f rename to examples/lapack/native/ssyswapr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytd2.f b/examples/lapack/native/ssytd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytd2.f rename to examples/lapack/native/ssytd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytf2.f b/examples/lapack/native/ssytf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytf2.f rename to examples/lapack/native/ssytf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytf2_rk.f b/examples/lapack/native/ssytf2_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytf2_rk.f rename to examples/lapack/native/ssytf2_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytf2_rook.f b/examples/lapack/native/ssytf2_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytf2_rook.f rename to examples/lapack/native/ssytf2_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd.f b/examples/lapack/native/ssytrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd.f rename to examples/lapack/native/ssytrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd_2stage.f b/examples/lapack/native/ssytrd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd_2stage.f rename to examples/lapack/native/ssytrd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd_sb2st.F b/examples/lapack/native/ssytrd_sb2st.F similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd_sb2st.F rename to examples/lapack/native/ssytrd_sb2st.F diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd_sy2sb.f b/examples/lapack/native/ssytrd_sy2sb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrd_sy2sb.f rename to examples/lapack/native/ssytrd_sy2sb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf.f b/examples/lapack/native/ssytrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf.f rename to examples/lapack/native/ssytrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_aa.f b/examples/lapack/native/ssytrf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_aa.f rename to examples/lapack/native/ssytrf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_aa_2stage.f b/examples/lapack/native/ssytrf_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_aa_2stage.f rename to examples/lapack/native/ssytrf_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_rk.f b/examples/lapack/native/ssytrf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_rk.f rename to examples/lapack/native/ssytrf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_rook.f b/examples/lapack/native/ssytrf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrf_rook.f rename to examples/lapack/native/ssytrf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri.f b/examples/lapack/native/ssytri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri.f rename to examples/lapack/native/ssytri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri2.f b/examples/lapack/native/ssytri2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri2.f rename to examples/lapack/native/ssytri2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri2x.f b/examples/lapack/native/ssytri2x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri2x.f rename to examples/lapack/native/ssytri2x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri_3.f b/examples/lapack/native/ssytri_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri_3.f rename to examples/lapack/native/ssytri_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri_3x.f b/examples/lapack/native/ssytri_3x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri_3x.f rename to examples/lapack/native/ssytri_3x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri_rook.f b/examples/lapack/native/ssytri_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytri_rook.f rename to examples/lapack/native/ssytri_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs.f b/examples/lapack/native/ssytrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs.f rename to examples/lapack/native/ssytrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs2.f b/examples/lapack/native/ssytrs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs2.f rename to examples/lapack/native/ssytrs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_3.f b/examples/lapack/native/ssytrs_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_3.f rename to examples/lapack/native/ssytrs_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_aa.f b/examples/lapack/native/ssytrs_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_aa.f rename to examples/lapack/native/ssytrs_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_aa_2stage.f b/examples/lapack/native/ssytrs_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_aa_2stage.f rename to examples/lapack/native/ssytrs_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_rook.f b/examples/lapack/native/ssytrs_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ssytrs_rook.f rename to examples/lapack/native/ssytrs_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stbcon.f b/examples/lapack/native/stbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stbcon.f rename to examples/lapack/native/stbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stbrfs.f b/examples/lapack/native/stbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stbrfs.f rename to examples/lapack/native/stbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stbtrs.f b/examples/lapack/native/stbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stbtrs.f rename to examples/lapack/native/stbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stfsm.f b/examples/lapack/native/stfsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stfsm.f rename to examples/lapack/native/stfsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stftri.f b/examples/lapack/native/stftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stftri.f rename to examples/lapack/native/stftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stfttp.f b/examples/lapack/native/stfttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stfttp.f rename to examples/lapack/native/stfttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stfttr.f b/examples/lapack/native/stfttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stfttr.f rename to examples/lapack/native/stfttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgevc.f b/examples/lapack/native/stgevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgevc.f rename to examples/lapack/native/stgevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgex2.f b/examples/lapack/native/stgex2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgex2.f rename to examples/lapack/native/stgex2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgexc.f b/examples/lapack/native/stgexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgexc.f rename to examples/lapack/native/stgexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsen.f b/examples/lapack/native/stgsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsen.f rename to examples/lapack/native/stgsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsja.f b/examples/lapack/native/stgsja.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsja.f rename to examples/lapack/native/stgsja.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsna.f b/examples/lapack/native/stgsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsna.f rename to examples/lapack/native/stgsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsy2.f b/examples/lapack/native/stgsy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsy2.f rename to examples/lapack/native/stgsy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsyl.f b/examples/lapack/native/stgsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stgsyl.f rename to examples/lapack/native/stgsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpcon.f b/examples/lapack/native/stpcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpcon.f rename to examples/lapack/native/stpcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stplqt.f b/examples/lapack/native/stplqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stplqt.f rename to examples/lapack/native/stplqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stplqt2.f b/examples/lapack/native/stplqt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stplqt2.f rename to examples/lapack/native/stplqt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpmlqt.f b/examples/lapack/native/stpmlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpmlqt.f rename to examples/lapack/native/stpmlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpmqrt.f b/examples/lapack/native/stpmqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpmqrt.f rename to examples/lapack/native/stpmqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpqrt.f b/examples/lapack/native/stpqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpqrt.f rename to examples/lapack/native/stpqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpqrt2.f b/examples/lapack/native/stpqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpqrt2.f rename to examples/lapack/native/stpqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stprfb.f b/examples/lapack/native/stprfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stprfb.f rename to examples/lapack/native/stprfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stprfs.f b/examples/lapack/native/stprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stprfs.f rename to examples/lapack/native/stprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stptri.f b/examples/lapack/native/stptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stptri.f rename to examples/lapack/native/stptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stptrs.f b/examples/lapack/native/stptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stptrs.f rename to examples/lapack/native/stptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpttf.f b/examples/lapack/native/stpttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpttf.f rename to examples/lapack/native/stpttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpttr.f b/examples/lapack/native/stpttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stpttr.f rename to examples/lapack/native/stpttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strcon.f b/examples/lapack/native/strcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strcon.f rename to examples/lapack/native/strcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strevc.f b/examples/lapack/native/strevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strevc.f rename to examples/lapack/native/strevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strevc3.f b/examples/lapack/native/strevc3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strevc3.f rename to examples/lapack/native/strevc3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strexc.f b/examples/lapack/native/strexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strexc.f rename to examples/lapack/native/strexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strrfs.f b/examples/lapack/native/strrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strrfs.f rename to examples/lapack/native/strrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsen.f b/examples/lapack/native/strsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsen.f rename to examples/lapack/native/strsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsna.f b/examples/lapack/native/strsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsna.f rename to examples/lapack/native/strsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsyl.f b/examples/lapack/native/strsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsyl.f rename to examples/lapack/native/strsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsyl3.f b/examples/lapack/native/strsyl3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strsyl3.f rename to examples/lapack/native/strsyl3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strti2.f b/examples/lapack/native/strti2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strti2.f rename to examples/lapack/native/strti2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strtri.f b/examples/lapack/native/strtri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strtri.f rename to examples/lapack/native/strtri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strtrs.f b/examples/lapack/native/strtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strtrs.f rename to examples/lapack/native/strtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strttf.f b/examples/lapack/native/strttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strttf.f rename to examples/lapack/native/strttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strttp.f b/examples/lapack/native/strttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/strttp.f rename to examples/lapack/native/strttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stzrzf.f b/examples/lapack/native/stzrzf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/stzrzf.f rename to examples/lapack/native/stzrzf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/xerbla.f b/examples/lapack/native/xerbla.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/xerbla.f rename to examples/lapack/native/xerbla.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/xerbla_array.f b/examples/lapack/native/xerbla_array.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/xerbla_array.f rename to examples/lapack/native/xerbla_array.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zbbcsd.f b/examples/lapack/native/zbbcsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zbbcsd.f rename to examples/lapack/native/zbbcsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zbdsqr.f b/examples/lapack/native/zbdsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zbdsqr.f rename to examples/lapack/native/zbdsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zcgesv.f b/examples/lapack/native/zcgesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zcgesv.f rename to examples/lapack/native/zcgesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zcposv.f b/examples/lapack/native/zcposv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zcposv.f rename to examples/lapack/native/zcposv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zdrscl.f b/examples/lapack/native/zdrscl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zdrscl.f rename to examples/lapack/native/zdrscl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbbrd.f b/examples/lapack/native/zgbbrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbbrd.f rename to examples/lapack/native/zgbbrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbcon.f b/examples/lapack/native/zgbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbcon.f rename to examples/lapack/native/zgbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbequ.f b/examples/lapack/native/zgbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbequ.f rename to examples/lapack/native/zgbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbequb.f b/examples/lapack/native/zgbequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbequb.f rename to examples/lapack/native/zgbequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbrfs.f b/examples/lapack/native/zgbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbrfs.f rename to examples/lapack/native/zgbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbrfsx.f b/examples/lapack/native/zgbrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbrfsx.f rename to examples/lapack/native/zgbrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbsv.f b/examples/lapack/native/zgbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbsv.f rename to examples/lapack/native/zgbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbsvx.f b/examples/lapack/native/zgbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbsvx.f rename to examples/lapack/native/zgbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbsvxx.f b/examples/lapack/native/zgbsvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbsvxx.f rename to examples/lapack/native/zgbsvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbtf2.f b/examples/lapack/native/zgbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbtf2.f rename to examples/lapack/native/zgbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbtrf.f b/examples/lapack/native/zgbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbtrf.f rename to examples/lapack/native/zgbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbtrs.f b/examples/lapack/native/zgbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgbtrs.f rename to examples/lapack/native/zgbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebak.f b/examples/lapack/native/zgebak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebak.f rename to examples/lapack/native/zgebak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebal.f b/examples/lapack/native/zgebal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebal.f rename to examples/lapack/native/zgebal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebd2.f b/examples/lapack/native/zgebd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebd2.f rename to examples/lapack/native/zgebd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebrd.f b/examples/lapack/native/zgebrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgebrd.f rename to examples/lapack/native/zgebrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgecon.f b/examples/lapack/native/zgecon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgecon.f rename to examples/lapack/native/zgecon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgedmd.f90 b/examples/lapack/native/zgedmd.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgedmd.f90 rename to examples/lapack/native/zgedmd.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgedmdq.f90 b/examples/lapack/native/zgedmdq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgedmdq.f90 rename to examples/lapack/native/zgedmdq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeequ.f b/examples/lapack/native/zgeequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeequ.f rename to examples/lapack/native/zgeequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeequb.f b/examples/lapack/native/zgeequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeequb.f rename to examples/lapack/native/zgeequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgees.f b/examples/lapack/native/zgees.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgees.f rename to examples/lapack/native/zgees.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeesx.f b/examples/lapack/native/zgeesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeesx.f rename to examples/lapack/native/zgeesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeev.f b/examples/lapack/native/zgeev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeev.f rename to examples/lapack/native/zgeev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeevx.f b/examples/lapack/native/zgeevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeevx.f rename to examples/lapack/native/zgeevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgehd2.f b/examples/lapack/native/zgehd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgehd2.f rename to examples/lapack/native/zgehd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgehrd.f b/examples/lapack/native/zgehrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgehrd.f rename to examples/lapack/native/zgehrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgejsv.f b/examples/lapack/native/zgejsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgejsv.f rename to examples/lapack/native/zgejsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelq.f b/examples/lapack/native/zgelq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelq.f rename to examples/lapack/native/zgelq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelq2.f b/examples/lapack/native/zgelq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelq2.f rename to examples/lapack/native/zgelq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelqf.f b/examples/lapack/native/zgelqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelqf.f rename to examples/lapack/native/zgelqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelqt.f b/examples/lapack/native/zgelqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelqt.f rename to examples/lapack/native/zgelqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelqt3.f b/examples/lapack/native/zgelqt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelqt3.f rename to examples/lapack/native/zgelqt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgels.f b/examples/lapack/native/zgels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgels.f rename to examples/lapack/native/zgels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelsd.f b/examples/lapack/native/zgelsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelsd.f rename to examples/lapack/native/zgelsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelss.f b/examples/lapack/native/zgelss.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelss.f rename to examples/lapack/native/zgelss.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelst.f b/examples/lapack/native/zgelst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelst.f rename to examples/lapack/native/zgelst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelsy.f b/examples/lapack/native/zgelsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgelsy.f rename to examples/lapack/native/zgelsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemlq.f b/examples/lapack/native/zgemlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemlq.f rename to examples/lapack/native/zgemlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemlqt.f b/examples/lapack/native/zgemlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemlqt.f rename to examples/lapack/native/zgemlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemqr.f b/examples/lapack/native/zgemqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemqr.f rename to examples/lapack/native/zgemqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemqrt.f b/examples/lapack/native/zgemqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgemqrt.f rename to examples/lapack/native/zgemqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeql2.f b/examples/lapack/native/zgeql2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeql2.f rename to examples/lapack/native/zgeql2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqlf.f b/examples/lapack/native/zgeqlf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqlf.f rename to examples/lapack/native/zgeqlf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqp3.f b/examples/lapack/native/zgeqp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqp3.f rename to examples/lapack/native/zgeqp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqp3rk.f b/examples/lapack/native/zgeqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqp3rk.f rename to examples/lapack/native/zgeqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqr.f b/examples/lapack/native/zgeqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqr.f rename to examples/lapack/native/zgeqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqr2.f b/examples/lapack/native/zgeqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqr2.f rename to examples/lapack/native/zgeqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqr2p.f b/examples/lapack/native/zgeqr2p.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqr2p.f rename to examples/lapack/native/zgeqr2p.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrf.f b/examples/lapack/native/zgeqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrf.f rename to examples/lapack/native/zgeqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrfp.f b/examples/lapack/native/zgeqrfp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrfp.f rename to examples/lapack/native/zgeqrfp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrt.f b/examples/lapack/native/zgeqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrt.f rename to examples/lapack/native/zgeqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrt2.f b/examples/lapack/native/zgeqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrt2.f rename to examples/lapack/native/zgeqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrt3.f b/examples/lapack/native/zgeqrt3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgeqrt3.f rename to examples/lapack/native/zgeqrt3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerfs.f b/examples/lapack/native/zgerfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerfs.f rename to examples/lapack/native/zgerfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerfsx.f b/examples/lapack/native/zgerfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerfsx.f rename to examples/lapack/native/zgerfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerq2.f b/examples/lapack/native/zgerq2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerq2.f rename to examples/lapack/native/zgerq2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerqf.f b/examples/lapack/native/zgerqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgerqf.f rename to examples/lapack/native/zgerqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesc2.f b/examples/lapack/native/zgesc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesc2.f rename to examples/lapack/native/zgesc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesdd.f b/examples/lapack/native/zgesdd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesdd.f rename to examples/lapack/native/zgesdd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesv.f b/examples/lapack/native/zgesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesv.f rename to examples/lapack/native/zgesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvd.f b/examples/lapack/native/zgesvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvd.f rename to examples/lapack/native/zgesvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvdq.f b/examples/lapack/native/zgesvdq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvdq.f rename to examples/lapack/native/zgesvdq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvdx.f b/examples/lapack/native/zgesvdx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvdx.f rename to examples/lapack/native/zgesvdx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvj.f b/examples/lapack/native/zgesvj.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvj.f rename to examples/lapack/native/zgesvj.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvx.f b/examples/lapack/native/zgesvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvx.f rename to examples/lapack/native/zgesvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvxx.f b/examples/lapack/native/zgesvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgesvxx.f rename to examples/lapack/native/zgesvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetc2.f b/examples/lapack/native/zgetc2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetc2.f rename to examples/lapack/native/zgetc2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetf2.f b/examples/lapack/native/zgetf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetf2.f rename to examples/lapack/native/zgetf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetrf.f b/examples/lapack/native/zgetrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetrf.f rename to examples/lapack/native/zgetrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetrf2.f b/examples/lapack/native/zgetrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetrf2.f rename to examples/lapack/native/zgetrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetri.f b/examples/lapack/native/zgetri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetri.f rename to examples/lapack/native/zgetri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetrs.f b/examples/lapack/native/zgetrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetrs.f rename to examples/lapack/native/zgetrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetsls.f b/examples/lapack/native/zgetsls.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetsls.f rename to examples/lapack/native/zgetsls.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetsqrhrt.f b/examples/lapack/native/zgetsqrhrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgetsqrhrt.f rename to examples/lapack/native/zgetsqrhrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggbak.f b/examples/lapack/native/zggbak.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggbak.f rename to examples/lapack/native/zggbak.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggbal.f b/examples/lapack/native/zggbal.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggbal.f rename to examples/lapack/native/zggbal.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgges.f b/examples/lapack/native/zgges.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgges.f rename to examples/lapack/native/zgges.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgges3.f b/examples/lapack/native/zgges3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgges3.f rename to examples/lapack/native/zgges3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggesx.f b/examples/lapack/native/zggesx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggesx.f rename to examples/lapack/native/zggesx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggev.f b/examples/lapack/native/zggev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggev.f rename to examples/lapack/native/zggev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggev3.f b/examples/lapack/native/zggev3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggev3.f rename to examples/lapack/native/zggev3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggevx.f b/examples/lapack/native/zggevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggevx.f rename to examples/lapack/native/zggevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggglm.f b/examples/lapack/native/zggglm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggglm.f rename to examples/lapack/native/zggglm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgghd3.f b/examples/lapack/native/zgghd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgghd3.f rename to examples/lapack/native/zgghd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgghrd.f b/examples/lapack/native/zgghrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgghrd.f rename to examples/lapack/native/zgghrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgglse.f b/examples/lapack/native/zgglse.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgglse.f rename to examples/lapack/native/zgglse.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggqrf.f b/examples/lapack/native/zggqrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggqrf.f rename to examples/lapack/native/zggqrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggrqf.f b/examples/lapack/native/zggrqf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggrqf.f rename to examples/lapack/native/zggrqf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggsvd3.f b/examples/lapack/native/zggsvd3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggsvd3.f rename to examples/lapack/native/zggsvd3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggsvp3.f b/examples/lapack/native/zggsvp3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zggsvp3.f rename to examples/lapack/native/zggsvp3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgsvj0.f b/examples/lapack/native/zgsvj0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgsvj0.f rename to examples/lapack/native/zgsvj0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgsvj1.f b/examples/lapack/native/zgsvj1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgsvj1.f rename to examples/lapack/native/zgsvj1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtcon.f b/examples/lapack/native/zgtcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtcon.f rename to examples/lapack/native/zgtcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtrfs.f b/examples/lapack/native/zgtrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtrfs.f rename to examples/lapack/native/zgtrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtsv.f b/examples/lapack/native/zgtsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtsv.f rename to examples/lapack/native/zgtsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtsvx.f b/examples/lapack/native/zgtsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtsvx.f rename to examples/lapack/native/zgtsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgttrf.f b/examples/lapack/native/zgttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgttrf.f rename to examples/lapack/native/zgttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgttrs.f b/examples/lapack/native/zgttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgttrs.f rename to examples/lapack/native/zgttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtts2.f b/examples/lapack/native/zgtts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zgtts2.f rename to examples/lapack/native/zgtts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhb2st_kernels.f b/examples/lapack/native/zhb2st_kernels.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhb2st_kernels.f rename to examples/lapack/native/zhb2st_kernels.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbev.f b/examples/lapack/native/zhbev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbev.f rename to examples/lapack/native/zhbev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbev_2stage.f b/examples/lapack/native/zhbev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbev_2stage.f rename to examples/lapack/native/zhbev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevd.f b/examples/lapack/native/zhbevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevd.f rename to examples/lapack/native/zhbevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevd_2stage.f b/examples/lapack/native/zhbevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevd_2stage.f rename to examples/lapack/native/zhbevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevx.f b/examples/lapack/native/zhbevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevx.f rename to examples/lapack/native/zhbevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevx_2stage.f b/examples/lapack/native/zhbevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbevx_2stage.f rename to examples/lapack/native/zhbevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgst.f b/examples/lapack/native/zhbgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgst.f rename to examples/lapack/native/zhbgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgv.f b/examples/lapack/native/zhbgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgv.f rename to examples/lapack/native/zhbgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgvd.f b/examples/lapack/native/zhbgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgvd.f rename to examples/lapack/native/zhbgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgvx.f b/examples/lapack/native/zhbgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbgvx.f rename to examples/lapack/native/zhbgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbtrd.f b/examples/lapack/native/zhbtrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhbtrd.f rename to examples/lapack/native/zhbtrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhecon.f b/examples/lapack/native/zhecon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhecon.f rename to examples/lapack/native/zhecon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhecon_3.f b/examples/lapack/native/zhecon_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhecon_3.f rename to examples/lapack/native/zhecon_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhecon_rook.f b/examples/lapack/native/zhecon_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhecon_rook.f rename to examples/lapack/native/zhecon_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheequb.f b/examples/lapack/native/zheequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheequb.f rename to examples/lapack/native/zheequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheev.f b/examples/lapack/native/zheev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheev.f rename to examples/lapack/native/zheev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheev_2stage.f b/examples/lapack/native/zheev_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheev_2stage.f rename to examples/lapack/native/zheev_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevd.f b/examples/lapack/native/zheevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevd.f rename to examples/lapack/native/zheevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevd_2stage.f b/examples/lapack/native/zheevd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevd_2stage.f rename to examples/lapack/native/zheevd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevr.f b/examples/lapack/native/zheevr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevr.f rename to examples/lapack/native/zheevr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevr_2stage.f b/examples/lapack/native/zheevr_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevr_2stage.f rename to examples/lapack/native/zheevr_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevx.f b/examples/lapack/native/zheevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevx.f rename to examples/lapack/native/zheevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevx_2stage.f b/examples/lapack/native/zheevx_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheevx_2stage.f rename to examples/lapack/native/zheevx_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegs2.f b/examples/lapack/native/zhegs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegs2.f rename to examples/lapack/native/zhegs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegst.f b/examples/lapack/native/zhegst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegst.f rename to examples/lapack/native/zhegst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegv.f b/examples/lapack/native/zhegv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegv.f rename to examples/lapack/native/zhegv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegv_2stage.f b/examples/lapack/native/zhegv_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegv_2stage.f rename to examples/lapack/native/zhegv_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegvd.f b/examples/lapack/native/zhegvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegvd.f rename to examples/lapack/native/zhegvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegvx.f b/examples/lapack/native/zhegvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhegvx.f rename to examples/lapack/native/zhegvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zherfs.f b/examples/lapack/native/zherfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zherfs.f rename to examples/lapack/native/zherfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zherfsx.f b/examples/lapack/native/zherfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zherfsx.f rename to examples/lapack/native/zherfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv.f b/examples/lapack/native/zhesv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv.f rename to examples/lapack/native/zhesv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_aa.f b/examples/lapack/native/zhesv_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_aa.f rename to examples/lapack/native/zhesv_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_aa_2stage.f b/examples/lapack/native/zhesv_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_aa_2stage.f rename to examples/lapack/native/zhesv_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_rk.f b/examples/lapack/native/zhesv_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_rk.f rename to examples/lapack/native/zhesv_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_rook.f b/examples/lapack/native/zhesv_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesv_rook.f rename to examples/lapack/native/zhesv_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesvx.f b/examples/lapack/native/zhesvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesvx.f rename to examples/lapack/native/zhesvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesvxx.f b/examples/lapack/native/zhesvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhesvxx.f rename to examples/lapack/native/zhesvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheswapr.f b/examples/lapack/native/zheswapr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zheswapr.f rename to examples/lapack/native/zheswapr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetd2.f b/examples/lapack/native/zhetd2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetd2.f rename to examples/lapack/native/zhetd2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetf2.f b/examples/lapack/native/zhetf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetf2.f rename to examples/lapack/native/zhetf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetf2_rk.f b/examples/lapack/native/zhetf2_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetf2_rk.f rename to examples/lapack/native/zhetf2_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetf2_rook.f b/examples/lapack/native/zhetf2_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetf2_rook.f rename to examples/lapack/native/zhetf2_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd.f b/examples/lapack/native/zhetrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd.f rename to examples/lapack/native/zhetrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd_2stage.f b/examples/lapack/native/zhetrd_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd_2stage.f rename to examples/lapack/native/zhetrd_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd_hb2st.F b/examples/lapack/native/zhetrd_hb2st.F similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd_hb2st.F rename to examples/lapack/native/zhetrd_hb2st.F diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd_he2hb.f b/examples/lapack/native/zhetrd_he2hb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrd_he2hb.f rename to examples/lapack/native/zhetrd_he2hb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf.f b/examples/lapack/native/zhetrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf.f rename to examples/lapack/native/zhetrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_aa.f b/examples/lapack/native/zhetrf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_aa.f rename to examples/lapack/native/zhetrf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_aa_2stage.f b/examples/lapack/native/zhetrf_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_aa_2stage.f rename to examples/lapack/native/zhetrf_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_rk.f b/examples/lapack/native/zhetrf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_rk.f rename to examples/lapack/native/zhetrf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_rook.f b/examples/lapack/native/zhetrf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrf_rook.f rename to examples/lapack/native/zhetrf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri.f b/examples/lapack/native/zhetri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri.f rename to examples/lapack/native/zhetri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri2.f b/examples/lapack/native/zhetri2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri2.f rename to examples/lapack/native/zhetri2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri2x.f b/examples/lapack/native/zhetri2x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri2x.f rename to examples/lapack/native/zhetri2x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri_3.f b/examples/lapack/native/zhetri_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri_3.f rename to examples/lapack/native/zhetri_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri_3x.f b/examples/lapack/native/zhetri_3x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri_3x.f rename to examples/lapack/native/zhetri_3x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri_rook.f b/examples/lapack/native/zhetri_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetri_rook.f rename to examples/lapack/native/zhetri_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs.f b/examples/lapack/native/zhetrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs.f rename to examples/lapack/native/zhetrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs2.f b/examples/lapack/native/zhetrs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs2.f rename to examples/lapack/native/zhetrs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_3.f b/examples/lapack/native/zhetrs_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_3.f rename to examples/lapack/native/zhetrs_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_aa.f b/examples/lapack/native/zhetrs_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_aa.f rename to examples/lapack/native/zhetrs_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_aa_2stage.f b/examples/lapack/native/zhetrs_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_aa_2stage.f rename to examples/lapack/native/zhetrs_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_rook.f b/examples/lapack/native/zhetrs_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhetrs_rook.f rename to examples/lapack/native/zhetrs_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhfrk.f b/examples/lapack/native/zhfrk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhfrk.f rename to examples/lapack/native/zhfrk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhgeqz.f b/examples/lapack/native/zhgeqz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhgeqz.f rename to examples/lapack/native/zhgeqz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpcon.f b/examples/lapack/native/zhpcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpcon.f rename to examples/lapack/native/zhpcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpev.f b/examples/lapack/native/zhpev.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpev.f rename to examples/lapack/native/zhpev.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpevd.f b/examples/lapack/native/zhpevd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpevd.f rename to examples/lapack/native/zhpevd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpevx.f b/examples/lapack/native/zhpevx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpevx.f rename to examples/lapack/native/zhpevx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgst.f b/examples/lapack/native/zhpgst.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgst.f rename to examples/lapack/native/zhpgst.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgv.f b/examples/lapack/native/zhpgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgv.f rename to examples/lapack/native/zhpgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgvd.f b/examples/lapack/native/zhpgvd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgvd.f rename to examples/lapack/native/zhpgvd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgvx.f b/examples/lapack/native/zhpgvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpgvx.f rename to examples/lapack/native/zhpgvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhprfs.f b/examples/lapack/native/zhprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhprfs.f rename to examples/lapack/native/zhprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpsv.f b/examples/lapack/native/zhpsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpsv.f rename to examples/lapack/native/zhpsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpsvx.f b/examples/lapack/native/zhpsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhpsvx.f rename to examples/lapack/native/zhpsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptrd.f b/examples/lapack/native/zhptrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptrd.f rename to examples/lapack/native/zhptrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptrf.f b/examples/lapack/native/zhptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptrf.f rename to examples/lapack/native/zhptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptri.f b/examples/lapack/native/zhptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptri.f rename to examples/lapack/native/zhptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptrs.f b/examples/lapack/native/zhptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhptrs.f rename to examples/lapack/native/zhptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhsein.f b/examples/lapack/native/zhsein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhsein.f rename to examples/lapack/native/zhsein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhseqr.f b/examples/lapack/native/zhseqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zhseqr.f rename to examples/lapack/native/zhseqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbamv.f b/examples/lapack/native/zla_gbamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbamv.f rename to examples/lapack/native/zla_gbamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrcond_c.f b/examples/lapack/native/zla_gbrcond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrcond_c.f rename to examples/lapack/native/zla_gbrcond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrcond_x.f b/examples/lapack/native/zla_gbrcond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrcond_x.f rename to examples/lapack/native/zla_gbrcond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrfsx_extended.f b/examples/lapack/native/zla_gbrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrfsx_extended.f rename to examples/lapack/native/zla_gbrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrpvgrw.f b/examples/lapack/native/zla_gbrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gbrpvgrw.f rename to examples/lapack/native/zla_gbrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_geamv.f b/examples/lapack/native/zla_geamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_geamv.f rename to examples/lapack/native/zla_geamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gercond_c.f b/examples/lapack/native/zla_gercond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gercond_c.f rename to examples/lapack/native/zla_gercond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gercond_x.f b/examples/lapack/native/zla_gercond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gercond_x.f rename to examples/lapack/native/zla_gercond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gerfsx_extended.f b/examples/lapack/native/zla_gerfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gerfsx_extended.f rename to examples/lapack/native/zla_gerfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gerpvgrw.f b/examples/lapack/native/zla_gerpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_gerpvgrw.f rename to examples/lapack/native/zla_gerpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_heamv.f b/examples/lapack/native/zla_heamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_heamv.f rename to examples/lapack/native/zla_heamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_hercond_c.f b/examples/lapack/native/zla_hercond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_hercond_c.f rename to examples/lapack/native/zla_hercond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_hercond_x.f b/examples/lapack/native/zla_hercond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_hercond_x.f rename to examples/lapack/native/zla_hercond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_herfsx_extended.f b/examples/lapack/native/zla_herfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_herfsx_extended.f rename to examples/lapack/native/zla_herfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_herpvgrw.f b/examples/lapack/native/zla_herpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_herpvgrw.f rename to examples/lapack/native/zla_herpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_lin_berr.f b/examples/lapack/native/zla_lin_berr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_lin_berr.f rename to examples/lapack/native/zla_lin_berr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porcond_c.f b/examples/lapack/native/zla_porcond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porcond_c.f rename to examples/lapack/native/zla_porcond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porcond_x.f b/examples/lapack/native/zla_porcond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porcond_x.f rename to examples/lapack/native/zla_porcond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porfsx_extended.f b/examples/lapack/native/zla_porfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porfsx_extended.f rename to examples/lapack/native/zla_porfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porpvgrw.f b/examples/lapack/native/zla_porpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_porpvgrw.f rename to examples/lapack/native/zla_porpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syamv.f b/examples/lapack/native/zla_syamv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syamv.f rename to examples/lapack/native/zla_syamv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrcond_c.f b/examples/lapack/native/zla_syrcond_c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrcond_c.f rename to examples/lapack/native/zla_syrcond_c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrcond_x.f b/examples/lapack/native/zla_syrcond_x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrcond_x.f rename to examples/lapack/native/zla_syrcond_x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrfsx_extended.f b/examples/lapack/native/zla_syrfsx_extended.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrfsx_extended.f rename to examples/lapack/native/zla_syrfsx_extended.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrpvgrw.f b/examples/lapack/native/zla_syrpvgrw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_syrpvgrw.f rename to examples/lapack/native/zla_syrpvgrw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_wwaddw.f b/examples/lapack/native/zla_wwaddw.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zla_wwaddw.f rename to examples/lapack/native/zla_wwaddw.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlabrd.f b/examples/lapack/native/zlabrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlabrd.f rename to examples/lapack/native/zlabrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacgv.f b/examples/lapack/native/zlacgv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacgv.f rename to examples/lapack/native/zlacgv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacn2.f b/examples/lapack/native/zlacn2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacn2.f rename to examples/lapack/native/zlacn2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacon.f b/examples/lapack/native/zlacon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacon.f rename to examples/lapack/native/zlacon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacp2.f b/examples/lapack/native/zlacp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacp2.f rename to examples/lapack/native/zlacp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacpy.f b/examples/lapack/native/zlacpy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacpy.f rename to examples/lapack/native/zlacpy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacrm.f b/examples/lapack/native/zlacrm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacrm.f rename to examples/lapack/native/zlacrm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacrt.f b/examples/lapack/native/zlacrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlacrt.f rename to examples/lapack/native/zlacrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zladiv.f b/examples/lapack/native/zladiv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zladiv.f rename to examples/lapack/native/zladiv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaed0.f b/examples/lapack/native/zlaed0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaed0.f rename to examples/lapack/native/zlaed0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaed7.f b/examples/lapack/native/zlaed7.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaed7.f rename to examples/lapack/native/zlaed7.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaed8.f b/examples/lapack/native/zlaed8.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaed8.f rename to examples/lapack/native/zlaed8.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaein.f b/examples/lapack/native/zlaein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaein.f rename to examples/lapack/native/zlaein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaesy.f b/examples/lapack/native/zlaesy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaesy.f rename to examples/lapack/native/zlaesy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaev2.f b/examples/lapack/native/zlaev2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaev2.f rename to examples/lapack/native/zlaev2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlag2c.f b/examples/lapack/native/zlag2c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlag2c.f rename to examples/lapack/native/zlag2c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlags2.f b/examples/lapack/native/zlags2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlags2.f rename to examples/lapack/native/zlags2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlagtm.f b/examples/lapack/native/zlagtm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlagtm.f rename to examples/lapack/native/zlagtm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef.f b/examples/lapack/native/zlahef.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef.f rename to examples/lapack/native/zlahef.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef_aa.f b/examples/lapack/native/zlahef_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef_aa.f rename to examples/lapack/native/zlahef_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef_rk.f b/examples/lapack/native/zlahef_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef_rk.f rename to examples/lapack/native/zlahef_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef_rook.f b/examples/lapack/native/zlahef_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahef_rook.f rename to examples/lapack/native/zlahef_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahqr.f b/examples/lapack/native/zlahqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahqr.f rename to examples/lapack/native/zlahqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahr2.f b/examples/lapack/native/zlahr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlahr2.f rename to examples/lapack/native/zlahr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaic1.f b/examples/lapack/native/zlaic1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaic1.f rename to examples/lapack/native/zlaic1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlals0.f b/examples/lapack/native/zlals0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlals0.f rename to examples/lapack/native/zlals0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlalsa.f b/examples/lapack/native/zlalsa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlalsa.f rename to examples/lapack/native/zlalsa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlalsd.f b/examples/lapack/native/zlalsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlalsd.f rename to examples/lapack/native/zlalsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlamswlq.f b/examples/lapack/native/zlamswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlamswlq.f rename to examples/lapack/native/zlamswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlamtsqr.f b/examples/lapack/native/zlamtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlamtsqr.f rename to examples/lapack/native/zlamtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlangb.f b/examples/lapack/native/zlangb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlangb.f rename to examples/lapack/native/zlangb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlange.f b/examples/lapack/native/zlange.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlange.f rename to examples/lapack/native/zlange.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlangt.f b/examples/lapack/native/zlangt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlangt.f rename to examples/lapack/native/zlangt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhb.f b/examples/lapack/native/zlanhb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhb.f rename to examples/lapack/native/zlanhb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhe.f b/examples/lapack/native/zlanhe.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhe.f rename to examples/lapack/native/zlanhe.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhf.f b/examples/lapack/native/zlanhf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhf.f rename to examples/lapack/native/zlanhf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhp.f b/examples/lapack/native/zlanhp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhp.f rename to examples/lapack/native/zlanhp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhs.f b/examples/lapack/native/zlanhs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanhs.f rename to examples/lapack/native/zlanhs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanht.f b/examples/lapack/native/zlanht.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlanht.f rename to examples/lapack/native/zlanht.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlansb.f b/examples/lapack/native/zlansb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlansb.f rename to examples/lapack/native/zlansb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlansp.f b/examples/lapack/native/zlansp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlansp.f rename to examples/lapack/native/zlansp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlansy.f b/examples/lapack/native/zlansy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlansy.f rename to examples/lapack/native/zlansy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlantb.f b/examples/lapack/native/zlantb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlantb.f rename to examples/lapack/native/zlantb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlantp.f b/examples/lapack/native/zlantp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlantp.f rename to examples/lapack/native/zlantp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlantr.f b/examples/lapack/native/zlantr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlantr.f rename to examples/lapack/native/zlantr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlapll.f b/examples/lapack/native/zlapll.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlapll.f rename to examples/lapack/native/zlapll.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlapmr.f b/examples/lapack/native/zlapmr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlapmr.f rename to examples/lapack/native/zlapmr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlapmt.f b/examples/lapack/native/zlapmt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlapmt.f rename to examples/lapack/native/zlapmt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqgb.f b/examples/lapack/native/zlaqgb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqgb.f rename to examples/lapack/native/zlaqgb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqge.f b/examples/lapack/native/zlaqge.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqge.f rename to examples/lapack/native/zlaqge.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqhb.f b/examples/lapack/native/zlaqhb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqhb.f rename to examples/lapack/native/zlaqhb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqhe.f b/examples/lapack/native/zlaqhe.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqhe.f rename to examples/lapack/native/zlaqhe.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqhp.f b/examples/lapack/native/zlaqhp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqhp.f rename to examples/lapack/native/zlaqhp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqp2.f b/examples/lapack/native/zlaqp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqp2.f rename to examples/lapack/native/zlaqp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqp2rk.f b/examples/lapack/native/zlaqp2rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqp2rk.f rename to examples/lapack/native/zlaqp2rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqp3rk.f b/examples/lapack/native/zlaqp3rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqp3rk.f rename to examples/lapack/native/zlaqp3rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqps.f b/examples/lapack/native/zlaqps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqps.f rename to examples/lapack/native/zlaqps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr0.f b/examples/lapack/native/zlaqr0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr0.f rename to examples/lapack/native/zlaqr0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr1.f b/examples/lapack/native/zlaqr1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr1.f rename to examples/lapack/native/zlaqr1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr2.f b/examples/lapack/native/zlaqr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr2.f rename to examples/lapack/native/zlaqr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr3.f b/examples/lapack/native/zlaqr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr3.f rename to examples/lapack/native/zlaqr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr4.f b/examples/lapack/native/zlaqr4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr4.f rename to examples/lapack/native/zlaqr4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr5.f b/examples/lapack/native/zlaqr5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqr5.f rename to examples/lapack/native/zlaqr5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqsb.f b/examples/lapack/native/zlaqsb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqsb.f rename to examples/lapack/native/zlaqsb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqsp.f b/examples/lapack/native/zlaqsp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqsp.f rename to examples/lapack/native/zlaqsp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqsy.f b/examples/lapack/native/zlaqsy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqsy.f rename to examples/lapack/native/zlaqsy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz0.f b/examples/lapack/native/zlaqz0.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz0.f rename to examples/lapack/native/zlaqz0.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz1.f b/examples/lapack/native/zlaqz1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz1.f rename to examples/lapack/native/zlaqz1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz2.f b/examples/lapack/native/zlaqz2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz2.f rename to examples/lapack/native/zlaqz2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz3.f b/examples/lapack/native/zlaqz3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaqz3.f rename to examples/lapack/native/zlaqz3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlar1v.f b/examples/lapack/native/zlar1v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlar1v.f rename to examples/lapack/native/zlar1v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlar2v.f b/examples/lapack/native/zlar2v.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlar2v.f rename to examples/lapack/native/zlar2v.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarcm.f b/examples/lapack/native/zlarcm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarcm.f rename to examples/lapack/native/zlarcm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarf.f b/examples/lapack/native/zlarf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarf.f rename to examples/lapack/native/zlarf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarf1f.f b/examples/lapack/native/zlarf1f.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarf1f.f rename to examples/lapack/native/zlarf1f.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarf1l.f b/examples/lapack/native/zlarf1l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarf1l.f rename to examples/lapack/native/zlarf1l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfb.f b/examples/lapack/native/zlarfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfb.f rename to examples/lapack/native/zlarfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfb_gett.f b/examples/lapack/native/zlarfb_gett.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfb_gett.f rename to examples/lapack/native/zlarfb_gett.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfg.f b/examples/lapack/native/zlarfg.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfg.f rename to examples/lapack/native/zlarfg.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfgp.f b/examples/lapack/native/zlarfgp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfgp.f rename to examples/lapack/native/zlarfgp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarft.f b/examples/lapack/native/zlarft.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarft.f rename to examples/lapack/native/zlarft.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfx.f b/examples/lapack/native/zlarfx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfx.f rename to examples/lapack/native/zlarfx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfy.f b/examples/lapack/native/zlarfy.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarfy.f rename to examples/lapack/native/zlarfy.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlargv.f b/examples/lapack/native/zlargv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlargv.f rename to examples/lapack/native/zlargv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarnv.f b/examples/lapack/native/zlarnv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarnv.f rename to examples/lapack/native/zlarnv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarrv.f b/examples/lapack/native/zlarrv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarrv.f rename to examples/lapack/native/zlarrv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarscl2.f b/examples/lapack/native/zlarscl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarscl2.f rename to examples/lapack/native/zlarscl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlartg.f90 b/examples/lapack/native/zlartg.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlartg.f90 rename to examples/lapack/native/zlartg.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlartv.f b/examples/lapack/native/zlartv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlartv.f rename to examples/lapack/native/zlartv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarz.f b/examples/lapack/native/zlarz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarz.f rename to examples/lapack/native/zlarz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarzb.f b/examples/lapack/native/zlarzb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarzb.f rename to examples/lapack/native/zlarzb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarzt.f b/examples/lapack/native/zlarzt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlarzt.f rename to examples/lapack/native/zlarzt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlascl.f b/examples/lapack/native/zlascl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlascl.f rename to examples/lapack/native/zlascl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlascl2.f b/examples/lapack/native/zlascl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlascl2.f rename to examples/lapack/native/zlascl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaset.f b/examples/lapack/native/zlaset.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaset.f rename to examples/lapack/native/zlaset.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasr.f b/examples/lapack/native/zlasr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasr.f rename to examples/lapack/native/zlasr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlassq.f90 b/examples/lapack/native/zlassq.f90 similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlassq.f90 rename to examples/lapack/native/zlassq.f90 diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaswlq.f b/examples/lapack/native/zlaswlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaswlq.f rename to examples/lapack/native/zlaswlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaswp.f b/examples/lapack/native/zlaswp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaswp.f rename to examples/lapack/native/zlaswp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf.f b/examples/lapack/native/zlasyf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf.f rename to examples/lapack/native/zlasyf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf_aa.f b/examples/lapack/native/zlasyf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf_aa.f rename to examples/lapack/native/zlasyf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf_rk.f b/examples/lapack/native/zlasyf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf_rk.f rename to examples/lapack/native/zlasyf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf_rook.f b/examples/lapack/native/zlasyf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlasyf_rook.f rename to examples/lapack/native/zlasyf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlat2c.f b/examples/lapack/native/zlat2c.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlat2c.f rename to examples/lapack/native/zlat2c.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatbs.f b/examples/lapack/native/zlatbs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatbs.f rename to examples/lapack/native/zlatbs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatdf.f b/examples/lapack/native/zlatdf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatdf.f rename to examples/lapack/native/zlatdf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatps.f b/examples/lapack/native/zlatps.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatps.f rename to examples/lapack/native/zlatps.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrd.f b/examples/lapack/native/zlatrd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrd.f rename to examples/lapack/native/zlatrd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrs.f b/examples/lapack/native/zlatrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrs.f rename to examples/lapack/native/zlatrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrs3.f b/examples/lapack/native/zlatrs3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrs3.f rename to examples/lapack/native/zlatrs3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrz.f b/examples/lapack/native/zlatrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatrz.f rename to examples/lapack/native/zlatrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatsqr.f b/examples/lapack/native/zlatsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlatsqr.f rename to examples/lapack/native/zlatsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaunhr_col_getrfnp.f b/examples/lapack/native/zlaunhr_col_getrfnp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaunhr_col_getrfnp.f rename to examples/lapack/native/zlaunhr_col_getrfnp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaunhr_col_getrfnp2.f b/examples/lapack/native/zlaunhr_col_getrfnp2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlaunhr_col_getrfnp2.f rename to examples/lapack/native/zlaunhr_col_getrfnp2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlauu2.f b/examples/lapack/native/zlauu2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlauu2.f rename to examples/lapack/native/zlauu2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlauum.f b/examples/lapack/native/zlauum.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zlauum.f rename to examples/lapack/native/zlauum.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbcon.f b/examples/lapack/native/zpbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbcon.f rename to examples/lapack/native/zpbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbequ.f b/examples/lapack/native/zpbequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbequ.f rename to examples/lapack/native/zpbequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbrfs.f b/examples/lapack/native/zpbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbrfs.f rename to examples/lapack/native/zpbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbstf.f b/examples/lapack/native/zpbstf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbstf.f rename to examples/lapack/native/zpbstf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbsv.f b/examples/lapack/native/zpbsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbsv.f rename to examples/lapack/native/zpbsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbsvx.f b/examples/lapack/native/zpbsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbsvx.f rename to examples/lapack/native/zpbsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbtf2.f b/examples/lapack/native/zpbtf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbtf2.f rename to examples/lapack/native/zpbtf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbtrf.f b/examples/lapack/native/zpbtrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbtrf.f rename to examples/lapack/native/zpbtrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbtrs.f b/examples/lapack/native/zpbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpbtrs.f rename to examples/lapack/native/zpbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpftrf.f b/examples/lapack/native/zpftrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpftrf.f rename to examples/lapack/native/zpftrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpftri.f b/examples/lapack/native/zpftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpftri.f rename to examples/lapack/native/zpftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpftrs.f b/examples/lapack/native/zpftrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpftrs.f rename to examples/lapack/native/zpftrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpocon.f b/examples/lapack/native/zpocon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpocon.f rename to examples/lapack/native/zpocon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpoequ.f b/examples/lapack/native/zpoequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpoequ.f rename to examples/lapack/native/zpoequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpoequb.f b/examples/lapack/native/zpoequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpoequb.f rename to examples/lapack/native/zpoequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zporfs.f b/examples/lapack/native/zporfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zporfs.f rename to examples/lapack/native/zporfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zporfsx.f b/examples/lapack/native/zporfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zporfsx.f rename to examples/lapack/native/zporfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zposv.f b/examples/lapack/native/zposv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zposv.f rename to examples/lapack/native/zposv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zposvx.f b/examples/lapack/native/zposvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zposvx.f rename to examples/lapack/native/zposvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zposvxx.f b/examples/lapack/native/zposvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zposvxx.f rename to examples/lapack/native/zposvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotf2.f b/examples/lapack/native/zpotf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotf2.f rename to examples/lapack/native/zpotf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotrf.f b/examples/lapack/native/zpotrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotrf.f rename to examples/lapack/native/zpotrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotrf2.f b/examples/lapack/native/zpotrf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotrf2.f rename to examples/lapack/native/zpotrf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotri.f b/examples/lapack/native/zpotri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotri.f rename to examples/lapack/native/zpotri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotrs.f b/examples/lapack/native/zpotrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpotrs.f rename to examples/lapack/native/zpotrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppcon.f b/examples/lapack/native/zppcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppcon.f rename to examples/lapack/native/zppcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppequ.f b/examples/lapack/native/zppequ.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppequ.f rename to examples/lapack/native/zppequ.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpprfs.f b/examples/lapack/native/zpprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpprfs.f rename to examples/lapack/native/zpprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppsv.f b/examples/lapack/native/zppsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppsv.f rename to examples/lapack/native/zppsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppsvx.f b/examples/lapack/native/zppsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zppsvx.f rename to examples/lapack/native/zppsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpptrf.f b/examples/lapack/native/zpptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpptrf.f rename to examples/lapack/native/zpptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpptri.f b/examples/lapack/native/zpptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpptri.f rename to examples/lapack/native/zpptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpptrs.f b/examples/lapack/native/zpptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpptrs.f rename to examples/lapack/native/zpptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpstf2.f b/examples/lapack/native/zpstf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpstf2.f rename to examples/lapack/native/zpstf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpstrf.f b/examples/lapack/native/zpstrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpstrf.f rename to examples/lapack/native/zpstrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptcon.f b/examples/lapack/native/zptcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptcon.f rename to examples/lapack/native/zptcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpteqr.f b/examples/lapack/native/zpteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpteqr.f rename to examples/lapack/native/zpteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptrfs.f b/examples/lapack/native/zptrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptrfs.f rename to examples/lapack/native/zptrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptsv.f b/examples/lapack/native/zptsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptsv.f rename to examples/lapack/native/zptsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptsvx.f b/examples/lapack/native/zptsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptsvx.f rename to examples/lapack/native/zptsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpttrf.f b/examples/lapack/native/zpttrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpttrf.f rename to examples/lapack/native/zpttrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpttrs.f b/examples/lapack/native/zpttrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zpttrs.f rename to examples/lapack/native/zpttrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptts2.f b/examples/lapack/native/zptts2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zptts2.f rename to examples/lapack/native/zptts2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zrot.f b/examples/lapack/native/zrot.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zrot.f rename to examples/lapack/native/zrot.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zrscl.f b/examples/lapack/native/zrscl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zrscl.f rename to examples/lapack/native/zrscl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspcon.f b/examples/lapack/native/zspcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspcon.f rename to examples/lapack/native/zspcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspmv.f b/examples/lapack/native/zspmv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspmv.f rename to examples/lapack/native/zspmv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspr.f b/examples/lapack/native/zspr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspr.f rename to examples/lapack/native/zspr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsprfs.f b/examples/lapack/native/zsprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsprfs.f rename to examples/lapack/native/zsprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspsv.f b/examples/lapack/native/zspsv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspsv.f rename to examples/lapack/native/zspsv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspsvx.f b/examples/lapack/native/zspsvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zspsvx.f rename to examples/lapack/native/zspsvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsptrf.f b/examples/lapack/native/zsptrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsptrf.f rename to examples/lapack/native/zsptrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsptri.f b/examples/lapack/native/zsptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsptri.f rename to examples/lapack/native/zsptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsptrs.f b/examples/lapack/native/zsptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsptrs.f rename to examples/lapack/native/zsptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstedc.f b/examples/lapack/native/zstedc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstedc.f rename to examples/lapack/native/zstedc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstegr.f b/examples/lapack/native/zstegr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstegr.f rename to examples/lapack/native/zstegr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstein.f b/examples/lapack/native/zstein.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstein.f rename to examples/lapack/native/zstein.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstemr.f b/examples/lapack/native/zstemr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zstemr.f rename to examples/lapack/native/zstemr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsteqr.f b/examples/lapack/native/zsteqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsteqr.f rename to examples/lapack/native/zsteqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsycon.f b/examples/lapack/native/zsycon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsycon.f rename to examples/lapack/native/zsycon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsycon_3.f b/examples/lapack/native/zsycon_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsycon_3.f rename to examples/lapack/native/zsycon_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsycon_rook.f b/examples/lapack/native/zsycon_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsycon_rook.f rename to examples/lapack/native/zsycon_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyconv.f b/examples/lapack/native/zsyconv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyconv.f rename to examples/lapack/native/zsyconv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyconvf.f b/examples/lapack/native/zsyconvf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyconvf.f rename to examples/lapack/native/zsyconvf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyconvf_rook.f b/examples/lapack/native/zsyconvf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyconvf_rook.f rename to examples/lapack/native/zsyconvf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyequb.f b/examples/lapack/native/zsyequb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyequb.f rename to examples/lapack/native/zsyequb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsymv.f b/examples/lapack/native/zsymv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsymv.f rename to examples/lapack/native/zsymv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyr.f b/examples/lapack/native/zsyr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyr.f rename to examples/lapack/native/zsyr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyrfs.f b/examples/lapack/native/zsyrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyrfs.f rename to examples/lapack/native/zsyrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyrfsx.f b/examples/lapack/native/zsyrfsx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyrfsx.f rename to examples/lapack/native/zsyrfsx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv.f b/examples/lapack/native/zsysv.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv.f rename to examples/lapack/native/zsysv.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_aa.f b/examples/lapack/native/zsysv_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_aa.f rename to examples/lapack/native/zsysv_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_aa_2stage.f b/examples/lapack/native/zsysv_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_aa_2stage.f rename to examples/lapack/native/zsysv_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_rk.f b/examples/lapack/native/zsysv_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_rk.f rename to examples/lapack/native/zsysv_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_rook.f b/examples/lapack/native/zsysv_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysv_rook.f rename to examples/lapack/native/zsysv_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysvx.f b/examples/lapack/native/zsysvx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysvx.f rename to examples/lapack/native/zsysvx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysvxx.f b/examples/lapack/native/zsysvxx.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsysvxx.f rename to examples/lapack/native/zsysvxx.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyswapr.f b/examples/lapack/native/zsyswapr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsyswapr.f rename to examples/lapack/native/zsyswapr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytf2.f b/examples/lapack/native/zsytf2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytf2.f rename to examples/lapack/native/zsytf2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytf2_rk.f b/examples/lapack/native/zsytf2_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytf2_rk.f rename to examples/lapack/native/zsytf2_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytf2_rook.f b/examples/lapack/native/zsytf2_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytf2_rook.f rename to examples/lapack/native/zsytf2_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf.f b/examples/lapack/native/zsytrf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf.f rename to examples/lapack/native/zsytrf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_aa.f b/examples/lapack/native/zsytrf_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_aa.f rename to examples/lapack/native/zsytrf_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_aa_2stage.f b/examples/lapack/native/zsytrf_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_aa_2stage.f rename to examples/lapack/native/zsytrf_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_rk.f b/examples/lapack/native/zsytrf_rk.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_rk.f rename to examples/lapack/native/zsytrf_rk.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_rook.f b/examples/lapack/native/zsytrf_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrf_rook.f rename to examples/lapack/native/zsytrf_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri.f b/examples/lapack/native/zsytri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri.f rename to examples/lapack/native/zsytri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri2.f b/examples/lapack/native/zsytri2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri2.f rename to examples/lapack/native/zsytri2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri2x.f b/examples/lapack/native/zsytri2x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri2x.f rename to examples/lapack/native/zsytri2x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri_3.f b/examples/lapack/native/zsytri_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri_3.f rename to examples/lapack/native/zsytri_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri_3x.f b/examples/lapack/native/zsytri_3x.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri_3x.f rename to examples/lapack/native/zsytri_3x.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri_rook.f b/examples/lapack/native/zsytri_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytri_rook.f rename to examples/lapack/native/zsytri_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs.f b/examples/lapack/native/zsytrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs.f rename to examples/lapack/native/zsytrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs2.f b/examples/lapack/native/zsytrs2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs2.f rename to examples/lapack/native/zsytrs2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_3.f b/examples/lapack/native/zsytrs_3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_3.f rename to examples/lapack/native/zsytrs_3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_aa.f b/examples/lapack/native/zsytrs_aa.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_aa.f rename to examples/lapack/native/zsytrs_aa.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_aa_2stage.f b/examples/lapack/native/zsytrs_aa_2stage.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_aa_2stage.f rename to examples/lapack/native/zsytrs_aa_2stage.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_rook.f b/examples/lapack/native/zsytrs_rook.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zsytrs_rook.f rename to examples/lapack/native/zsytrs_rook.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztbcon.f b/examples/lapack/native/ztbcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztbcon.f rename to examples/lapack/native/ztbcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztbrfs.f b/examples/lapack/native/ztbrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztbrfs.f rename to examples/lapack/native/ztbrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztbtrs.f b/examples/lapack/native/ztbtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztbtrs.f rename to examples/lapack/native/ztbtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztfsm.f b/examples/lapack/native/ztfsm.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztfsm.f rename to examples/lapack/native/ztfsm.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztftri.f b/examples/lapack/native/ztftri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztftri.f rename to examples/lapack/native/ztftri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztfttp.f b/examples/lapack/native/ztfttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztfttp.f rename to examples/lapack/native/ztfttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztfttr.f b/examples/lapack/native/ztfttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztfttr.f rename to examples/lapack/native/ztfttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgevc.f b/examples/lapack/native/ztgevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgevc.f rename to examples/lapack/native/ztgevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgex2.f b/examples/lapack/native/ztgex2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgex2.f rename to examples/lapack/native/ztgex2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgexc.f b/examples/lapack/native/ztgexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgexc.f rename to examples/lapack/native/ztgexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsen.f b/examples/lapack/native/ztgsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsen.f rename to examples/lapack/native/ztgsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsja.f b/examples/lapack/native/ztgsja.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsja.f rename to examples/lapack/native/ztgsja.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsna.f b/examples/lapack/native/ztgsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsna.f rename to examples/lapack/native/ztgsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsy2.f b/examples/lapack/native/ztgsy2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsy2.f rename to examples/lapack/native/ztgsy2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsyl.f b/examples/lapack/native/ztgsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztgsyl.f rename to examples/lapack/native/ztgsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpcon.f b/examples/lapack/native/ztpcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpcon.f rename to examples/lapack/native/ztpcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztplqt.f b/examples/lapack/native/ztplqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztplqt.f rename to examples/lapack/native/ztplqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztplqt2.f b/examples/lapack/native/ztplqt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztplqt2.f rename to examples/lapack/native/ztplqt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpmlqt.f b/examples/lapack/native/ztpmlqt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpmlqt.f rename to examples/lapack/native/ztpmlqt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpmqrt.f b/examples/lapack/native/ztpmqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpmqrt.f rename to examples/lapack/native/ztpmqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpqrt.f b/examples/lapack/native/ztpqrt.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpqrt.f rename to examples/lapack/native/ztpqrt.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpqrt2.f b/examples/lapack/native/ztpqrt2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpqrt2.f rename to examples/lapack/native/ztpqrt2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztprfb.f b/examples/lapack/native/ztprfb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztprfb.f rename to examples/lapack/native/ztprfb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztprfs.f b/examples/lapack/native/ztprfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztprfs.f rename to examples/lapack/native/ztprfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztptri.f b/examples/lapack/native/ztptri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztptri.f rename to examples/lapack/native/ztptri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztptrs.f b/examples/lapack/native/ztptrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztptrs.f rename to examples/lapack/native/ztptrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpttf.f b/examples/lapack/native/ztpttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpttf.f rename to examples/lapack/native/ztpttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpttr.f b/examples/lapack/native/ztpttr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztpttr.f rename to examples/lapack/native/ztpttr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrcon.f b/examples/lapack/native/ztrcon.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrcon.f rename to examples/lapack/native/ztrcon.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrevc.f b/examples/lapack/native/ztrevc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrevc.f rename to examples/lapack/native/ztrevc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrevc3.f b/examples/lapack/native/ztrevc3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrevc3.f rename to examples/lapack/native/ztrevc3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrexc.f b/examples/lapack/native/ztrexc.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrexc.f rename to examples/lapack/native/ztrexc.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrrfs.f b/examples/lapack/native/ztrrfs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrrfs.f rename to examples/lapack/native/ztrrfs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsen.f b/examples/lapack/native/ztrsen.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsen.f rename to examples/lapack/native/ztrsen.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsna.f b/examples/lapack/native/ztrsna.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsna.f rename to examples/lapack/native/ztrsna.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsyl.f b/examples/lapack/native/ztrsyl.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsyl.f rename to examples/lapack/native/ztrsyl.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsyl3.f b/examples/lapack/native/ztrsyl3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrsyl3.f rename to examples/lapack/native/ztrsyl3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrti2.f b/examples/lapack/native/ztrti2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrti2.f rename to examples/lapack/native/ztrti2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrtri.f b/examples/lapack/native/ztrtri.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrtri.f rename to examples/lapack/native/ztrtri.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrtrs.f b/examples/lapack/native/ztrtrs.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrtrs.f rename to examples/lapack/native/ztrtrs.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrttf.f b/examples/lapack/native/ztrttf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrttf.f rename to examples/lapack/native/ztrttf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrttp.f b/examples/lapack/native/ztrttp.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztrttp.f rename to examples/lapack/native/ztrttp.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztzrzf.f b/examples/lapack/native/ztzrzf.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/ztzrzf.f rename to examples/lapack/native/ztzrzf.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb.f b/examples/lapack/native/zunbdb.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb.f rename to examples/lapack/native/zunbdb.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb1.f b/examples/lapack/native/zunbdb1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb1.f rename to examples/lapack/native/zunbdb1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb2.f b/examples/lapack/native/zunbdb2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb2.f rename to examples/lapack/native/zunbdb2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb3.f b/examples/lapack/native/zunbdb3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb3.f rename to examples/lapack/native/zunbdb3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb4.f b/examples/lapack/native/zunbdb4.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb4.f rename to examples/lapack/native/zunbdb4.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb5.f b/examples/lapack/native/zunbdb5.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb5.f rename to examples/lapack/native/zunbdb5.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb6.f b/examples/lapack/native/zunbdb6.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunbdb6.f rename to examples/lapack/native/zunbdb6.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zuncsd.f b/examples/lapack/native/zuncsd.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zuncsd.f rename to examples/lapack/native/zuncsd.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zuncsd2by1.f b/examples/lapack/native/zuncsd2by1.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zuncsd2by1.f rename to examples/lapack/native/zuncsd2by1.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zung2l.f b/examples/lapack/native/zung2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zung2l.f rename to examples/lapack/native/zung2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zung2r.f b/examples/lapack/native/zung2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zung2r.f rename to examples/lapack/native/zung2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungbr.f b/examples/lapack/native/zungbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungbr.f rename to examples/lapack/native/zungbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunghr.f b/examples/lapack/native/zunghr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunghr.f rename to examples/lapack/native/zunghr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungl2.f b/examples/lapack/native/zungl2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungl2.f rename to examples/lapack/native/zungl2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunglq.f b/examples/lapack/native/zunglq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunglq.f rename to examples/lapack/native/zunglq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungql.f b/examples/lapack/native/zungql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungql.f rename to examples/lapack/native/zungql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungqr.f b/examples/lapack/native/zungqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungqr.f rename to examples/lapack/native/zungqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungr2.f b/examples/lapack/native/zungr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungr2.f rename to examples/lapack/native/zungr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungrq.f b/examples/lapack/native/zungrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungrq.f rename to examples/lapack/native/zungrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungtr.f b/examples/lapack/native/zungtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungtr.f rename to examples/lapack/native/zungtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungtsqr.f b/examples/lapack/native/zungtsqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungtsqr.f rename to examples/lapack/native/zungtsqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungtsqr_row.f b/examples/lapack/native/zungtsqr_row.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zungtsqr_row.f rename to examples/lapack/native/zungtsqr_row.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunhr_col.f b/examples/lapack/native/zunhr_col.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunhr_col.f rename to examples/lapack/native/zunhr_col.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunm22.f b/examples/lapack/native/zunm22.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunm22.f rename to examples/lapack/native/zunm22.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunm2l.f b/examples/lapack/native/zunm2l.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunm2l.f rename to examples/lapack/native/zunm2l.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunm2r.f b/examples/lapack/native/zunm2r.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunm2r.f rename to examples/lapack/native/zunm2r.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmbr.f b/examples/lapack/native/zunmbr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmbr.f rename to examples/lapack/native/zunmbr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmhr.f b/examples/lapack/native/zunmhr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmhr.f rename to examples/lapack/native/zunmhr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunml2.f b/examples/lapack/native/zunml2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunml2.f rename to examples/lapack/native/zunml2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmlq.f b/examples/lapack/native/zunmlq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmlq.f rename to examples/lapack/native/zunmlq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmql.f b/examples/lapack/native/zunmql.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmql.f rename to examples/lapack/native/zunmql.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmqr.f b/examples/lapack/native/zunmqr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmqr.f rename to examples/lapack/native/zunmqr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmr2.f b/examples/lapack/native/zunmr2.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmr2.f rename to examples/lapack/native/zunmr2.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmr3.f b/examples/lapack/native/zunmr3.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmr3.f rename to examples/lapack/native/zunmr3.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmrq.f b/examples/lapack/native/zunmrq.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmrq.f rename to examples/lapack/native/zunmrq.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmrz.f b/examples/lapack/native/zunmrz.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmrz.f rename to examples/lapack/native/zunmrz.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmtr.f b/examples/lapack/native/zunmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zunmtr.f rename to examples/lapack/native/zunmtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zupgtr.f b/examples/lapack/native/zupgtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zupgtr.f rename to examples/lapack/native/zupgtr.f diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zupmtr.f b/examples/lapack/native/zupmtr.f similarity index 100% rename from tests/fortran/building_shared_library/end_to_end/real_libraries/lapack/native/zupmtr.f rename to examples/lapack/native/zupmtr.f diff --git a/examples/lapack/routine_inventory.py b/examples/lapack/routine_inventory.py new file mode 100644 index 000000000..3998db07d --- /dev/null +++ b/examples/lapack/routine_inventory.py @@ -0,0 +1,504 @@ +"""Reviewed SciPy 1.18.0 float64 LAPACK inventory and LAPACK family ownership.""" + +from __future__ import annotations + +from dataclasses import dataclass + +SCIPY_VERSION = "1.18.0" +EXPECTED_LAPACK_SOURCE_FILES = 2062 +EXPECTED_LAPACK_PROCEDURES = 2066 +F2PY_SCALAR_WRITEBACK_ROUTINES = frozenset( + {"dlarfg", "dlartg", "dgbcon", "dgecon", "dgtcon", "dpocon", "dppcon", "dsycon", "dtrcon"} +) + +F2PY_FUNCTION_RESULTS = frozenset({"dlamch", "dlangb", "dlange", "dlantr"}) +ROUTINE_GROUPS = { + "auxiliary": ( + "dlamch", + "dlangb", + "dlange", + "dlantr", + "dlarf", + "dlarfg", + "dlartg", + "dlaswp", + ), + "linear_general": ( + "dgecon", + "dgeequ", + "dgeequb", + "dgesc2", + "dgesv", + "dgesvx", + "dgetc2", + "dgetrf", + "dgetri", + "dgetrs", + ), + "linear_symmetric_indefinite": ( + "dsycon", + "dsyconv", + "dsyequb", + "dsysv", + "dsysvx", + "dsytf2", + "dsytrf", + "dsytri", + "dsytrs", + ), + "linear_positive_definite": ( + "dlauum", + "dpftrf", + "dpftri", + "dpftrs", + "dpocon", + "dposv", + "dposvx", + "dpotrf", + "dpotri", + "dpotrs", + "dppcon", + "dppsv", + "dpptrf", + "dpptri", + "dpptrs", + "dpstf2", + "dpstrf", + "dsfrk", + ), + "linear_banded_tridiagonal": ( + "dgbcon", + "dgbsv", + "dgbtrf", + "dgbtrs", + "dgtcon", + "dgtsv", + "dgtsvx", + "dgttrf", + "dgttrs", + "dpbsv", + "dpbtrf", + "dpbtrs", + "dptsv", + "dptsvx", + "dpttrf", + "dpttrs", + "dtbtrs", + ), + "linear_triangular": ( + "dtfsm", + "dtfttp", + "dtfttr", + "dtpttf", + "dtpttr", + "dtrcon", + "dtrtri", + "dtrtrs", + "dtrttf", + "dtrttp", + ), + "least_squares": ( + "dgels", + "dgelsd", + "dgelss", + "dgelsy", + "dgglse", + ), + "orthogonal_factorizations": ( + "dgemqrt", + "dgeqp3", + "dgeqrf", + "dgeqrfp", + "dgeqrt", + "dgerqf", + "dorgqr", + "dorgrq", + "dormqr", + "dormrz", + "dtpmqrt", + "dtpqrt", + "dtzrzf", + ), + "eigen_nonsymmetric": ( + "dgebal", + "dgees", + "dgeev", + "dgehrd", + "dorghr", + "dtrexc", + "dtrsen", + "dtrsyl", + ), + "eigen_symmetric": ( + "dpteqr", + "dsbev", + "dsbevd", + "dsbevx", + "dstebz", + "dstein", + "dstemr", + "dsterf", + "dstev", + "dstevd", + "dsyev", + "dsyevd", + "dsyevr", + "dsyevx", + "dsytrd", + ), + "eigen_generalized": ( + "dgges", + "dggev", + "dsygst", + "dsygv", + "dsygvd", + "dsygvx", + "dtgexc", + "dtgsen", + "dtgsyl", + ), + "svd": ( + "dgejsv", + "dgesdd", + "dgesvd", + "dorcsd", + "dlasd4", + ), +} + +ROUTINES = tuple(name for names in ROUTINE_GROUPS.values() for name in names) +ROUTINE_FAMILIES = {name: family for family, names in ROUTINE_GROUPS.items() for name in names} +EXPLICIT_TEST_NAMES = { + "dlamch": "test_dlamch_reports_float64_machine_epsilon", + "dlangb": "test_dlangb_computes_frobenius_norm_of_band_storage", + "dlange": "test_dlange_computes_one_norm", + "dlantr": "test_dlantr_ignores_unused_triangle_and_unit_diagonal", + "dlarf": "test_dlarf_applies_householder_reflector_from_left", + "dlarfg": "test_dlarfg_constructs_a_valid_householder_reflector", + "dlartg": "test_dlartg_constructs_a_givens_rotation", + "dlaswp": "test_dlaswp_applies_native_one_based_row_pivots", + "dgecon": "test_dgecon_estimates_reciprocal_condition", + "dgeequ": "test_dgeequ_computes_row_and_column_scaling", + "dgeequb": "test_dgeequb_computes_radix_scaling", + "dgesc2": "test_dgesc2_solves_complete_pivot_lu_system", + "dgesv": "test_dgesv_solves_general_system", + "dgesvx": "test_dgesvx_solves_and_reports_error_bounds", + "dgetc2": "test_dgetc2_factorizes_with_complete_pivoting", + "dgetrf": "test_dgetrf_reconstructs_pivoted_lu", + "dgetri": "test_dgetri_inverts_lu_factorization", + "dgetrs": "test_dgetrs_solves_from_native_lu", + "dsycon": "test_dsycon_estimates_symmetric_reciprocal_condition", + "dsyconv": "test_dsyconv_converts_bunch_kaufman_storage", + "dsyequb": "test_dsyequb_scales_symmetric_matrix", + "dsysv": "test_dsysv_solves_symmetric_indefinite_system", + "dsysvx": "test_dsysvx_solves_and_bounds_symmetric_error", + "dsytf2": "test_dsytf2_factorizes_symmetric_indefinite_matrix", + "dsytrf": "test_dsytrf_factorizes_symmetric_indefinite_matrix", + "dsytri": "test_dsytri_inverts_symmetric_indefinite_factor", + "dsytrs": "test_dsytrs_solves_from_symmetric_indefinite_factor", + "dlauum": "test_dlauum_forms_triangular_product", + "dpftrf": "test_dpftrf_factorizes_rfp_spd_matrix", + "dpftri": "test_dpftri_inverts_rfp_cholesky_factor", + "dpftrs": "test_dpftrs_solves_from_rfp_cholesky_factor", + "dpocon": "test_dpocon_estimates_spd_reciprocal_condition", + "dposv": "test_dposv_solves_spd_system", + "dposvx": "test_dposvx_solves_and_bounds_spd_error", + "dpotrf": "test_dpotrf_reconstructs_spd_matrix", + "dpotri": "test_dpotri_inverts_cholesky_factor", + "dpotrs": "test_dpotrs_solves_from_cholesky_factor", + "dppcon": "test_dppcon_estimates_packed_spd_condition", + "dppsv": "test_dppsv_solves_packed_spd_system", + "dpptrf": "test_dpptrf_factorizes_packed_spd_matrix", + "dpptri": "test_dpptri_inverts_packed_cholesky_factor", + "dpptrs": "test_dpptrs_solves_from_packed_cholesky_factor", + "dpstf2": "test_dpstf2_reconstructs_pivoted_cholesky", + "dpstrf": "test_dpstrf_reconstructs_blocked_pivoted_cholesky", + "dsfrk": "test_dsfrk_updates_spd_matrix_in_rfp_storage", + "dgbcon": "test_dgbcon_estimates_general_band_condition", + "dgbsv": "test_dgbsv_solves_general_band_system", + "dgbtrf": "test_dgbtrf_factorizes_general_band_matrix", + "dgbtrs": "test_dgbtrs_solves_from_general_band_lu", + "dgtcon": "test_dgtcon_estimates_tridiagonal_condition", + "dgtsv": "test_dgtsv_solves_general_tridiagonal_system", + "dgtsvx": "test_dgtsvx_solves_and_bounds_tridiagonal_error", + "dgttrf": "test_dgttrf_factorizes_general_tridiagonal_matrix", + "dgttrs": "test_dgttrs_solves_from_tridiagonal_lu", + "dpbsv": "test_dpbsv_solves_positive_definite_band_system", + "dpbtrf": "test_dpbtrf_factorizes_positive_definite_band_matrix", + "dpbtrs": "test_dpbtrs_solves_from_positive_definite_band_factor", + "dptsv": "test_dptsv_solves_spd_tridiagonal_system", + "dptsvx": "test_dptsvx_solves_and_bounds_spd_tridiagonal_error", + "dpttrf": "test_dpttrf_factorizes_spd_tridiagonal_matrix", + "dpttrs": "test_dpttrs_solves_from_spd_tridiagonal_factor", + "dtbtrs": "test_dtbtrs_solves_triangular_band_system", + "dtfsm": "test_dtfsm_solves_with_rfp_triangular_factor", + "dtfttp": "test_dtfttp_converts_rfp_to_packed", + "dtfttr": "test_dtfttr_converts_rfp_to_full_triangular", + "dtpttf": "test_dtpttf_converts_packed_to_rfp", + "dtpttr": "test_dtpttr_converts_packed_to_full_triangular", + "dtrcon": "test_dtrcon_estimates_triangular_reciprocal_condition", + "dtrtri": "test_dtrtri_inverts_triangular_matrix", + "dtrtrs": "test_dtrtrs_solves_triangular_system", + "dtrttf": "test_dtrttf_converts_full_triangular_to_rfp", + "dtrttp": "test_dtrttp_converts_full_triangular_to_packed", + "dgels": "test_dgels_solves_full_rank_least_squares", + "dgelsd": "test_dgelsd_solves_rank_revealing_least_squares", + "dgelss": "test_dgelss_solves_svd_least_squares", + "dgelsy": "test_dgelsy_solves_pivoted_rank_revealing_least_squares", + "dgglse": "test_dgglse_solves_equality_constrained_least_squares", + "dgemqrt": "test_dgemqrt_applies_compact_wy_reflector", + "dgeqp3": "test_dgeqp3_reconstructs_column_pivoted_qr", + "dgeqrf": "test_dgeqrf_reconstructs_qr_factorization", + "dgeqrfp": "test_dgeqrfp_reconstructs_qr_with_nonnegative_diagonal", + "dgeqrt": "test_dgeqrt_reconstructs_compact_wy_qr", + "dgerqf": "test_dgerqf_reconstructs_rq_factorization", + "dorgqr": "test_dorgqr_forms_explicit_orthogonal_q", + "dorgrq": "test_dorgrq_forms_explicit_row_orthogonal_q", + "dormqr": "test_dormqr_applies_qr_reflectors", + "dormrz": "test_dormrz_applies_rz_reflector", + "dtpmqrt": "test_dtpmqrt_applies_triangular_pentagonal_reflector", + "dtpqrt": "test_dtpqrt_reconstructs_triangular_pentagonal_qr", + "dtzrzf": "test_dtzrzf_reconstructs_rz_factorization", + "dgebal": "test_dgebal_preserves_eigenvalues_while_balancing", + "dgees": "test_dgees_computes_real_schur_decomposition", + "dgeev": "test_dgeev_returns_right_eigenvectors", + "dgehrd": "test_dgehrd_reduces_matrix_to_upper_hessenberg", + "dorghr": "test_dorghr_forms_hessenberg_similarity_transform", + "dtrexc": "test_dtrexc_reorders_real_schur_blocks", + "dtrsen": "test_dtrsen_reorders_selected_schur_eigenvalue", + "dtrsyl": "test_dtrsyl_solves_sylvester_equation", + "dpteqr": "test_dpteqr_diagonalizes_positive_definite_tridiagonal", + "dsbev": "test_dsbev_diagonalizes_symmetric_band_matrix", + "dsbevd": "test_dsbevd_diagonalizes_band_matrix_by_divide_and_conquer", + "dsbevx": "test_dsbevx_selects_all_symmetric_band_eigenpairs", + "dstebz": "test_dstebz_bisects_tridiagonal_eigenvalues", + "dstein": "test_dstein_computes_tridiagonal_eigenvectors", + "dstemr": "test_dstemr_computes_robust_tridiagonal_eigenpairs", + "dsterf": "test_dsterf_computes_tridiagonal_eigenvalues", + "dstev": "test_dstev_computes_tridiagonal_eigenpairs", + "dstevd": "test_dstevd_computes_divide_and_conquer_tridiagonal_eigenpairs", + "dsyev": "test_dsyev_returns_orthonormal_eigenvectors", + "dsyevd": "test_dsyevd_computes_divide_and_conquer_symmetric_eigenpairs", + "dsyevr": "test_dsyevr_selects_symmetric_eigenpairs_by_index", + "dsyevx": "test_dsyevx_selects_symmetric_eigenpairs_by_value", + "dsytrd": "test_dsytrd_reduces_symmetric_matrix_to_tridiagonal", + "dgges": "test_dgges_computes_generalized_real_schur_form", + "dggev": "test_dggev_computes_generalized_right_eigenvectors", + "dsygst": "test_dsygst_reduces_symmetric_generalized_problem", + "dsygv": "test_dsygv_solves_symmetric_generalized_eigenproblem", + "dsygvd": "test_dsygvd_solves_divide_and_conquer_generalized_problem", + "dsygvx": "test_dsygvx_selects_generalized_eigenpairs", + "dtgexc": "test_dtgexc_reorders_generalized_schur_blocks", + "dtgsen": "test_dtgsen_reorders_selected_generalized_eigenvalue", + "dtgsyl": "test_dtgsyl_solves_generalized_sylvester_equations", + "dgejsv": "test_dgejsv_reconstructs_matrix_with_jacobi_svd", + "dgesdd": "test_dgesdd_reconstructs_matrix_with_divide_and_conquer_svd", + "dgesvd": "test_dgesvd_reconstructs_matrix", + "dorcsd": "test_dorcsd_decomposes_partitioned_orthogonal_matrix", + "dlasd4": "test_dlasd4_solves_rank_one_secular_equation", +} + +WORKSPACE_ROUTINES = frozenset( + { + "dgbcon", + "dgecon", + "dgemqrt", + "dgees", + "dgeev", + "dgehrd", + "dgejsv", + "dgels", + "dgelsd", + "dgelss", + "dgelsy", + "dgeqp3", + "dgeqrf", + "dgeqrfp", + "dgeqrt", + "dgerqf", + "dgesdd", + "dgesvd", + "dgesvx", + "dgetri", + "dgges", + "dggev", + "dgglse", + "dgtcon", + "dgtsvx", + "dlangb", + "dlange", + "dlantr", + "dlarf", + "dlasd4", + "dorcsd", + "dorghr", + "dorgqr", + "dorgrq", + "dormqr", + "dormrz", + "dpocon", + "dposvx", + "dppcon", + "dpstf2", + "dpstrf", + "dpteqr", + "dptsvx", + "dsbev", + "dsbevd", + "dsbevx", + "dstebz", + "dstein", + "dstemr", + "dstev", + "dstevd", + "dsycon", + "dsyequb", + "dsyev", + "dsyevd", + "dsyevr", + "dsyevx", + "dsygvd", + "dsygv", + "dsygvx", + "dsysv", + "dsysvx", + "dsytrd", + "dsytrf", + "dsytri", + "dtgexc", + "dtgsen", + "dtgsyl", + "dtpmqrt", + "dtpqrt", + "dtrcon", + "dtrexc", + "dtrsen", + "dtzrzf", + } +) + +INDEX_ROUTINES = frozenset( + { + "dgbcon", + "dgbsv", + "dgbtrf", + "dgbtrs", + "dgebal", + "dgeqp3", + "dgesc2", + "dgesv", + "dgesvx", + "dgetc2", + "dgetrf", + "dgetri", + "dgetrs", + "dgtcon", + "dgtsvx", + "dgttrf", + "dgttrs", + "dgelsy", + "dlasd4", + "dlaswp", + "dpstf2", + "dpstrf", + "dsbevx", + "dstebz", + "dstein", + "dstemr", + "dsyevr", + "dsyevx", + "dsycon", + "dsyconv", + "dsysv", + "dsysvx", + "dsytf2", + "dsytrf", + "dsytri", + "dsytrs", + "dsygvx", + "dtgexc", + "dtgsen", + "dtrexc", + } +) + +ORACLE_BY_FAMILY = { + "auxiliary": "explicit machine, norm, reflector, rotation, or permutation identity", + "linear_general": "solution residual, LU reconstruction, inverse identity, scaling, or condition estimate", + "linear_symmetric_indefinite": "solution residual, Bunch-Kaufman factor behavior, inverse, scaling, or condition estimate", + "linear_positive_definite": "Cholesky reconstruction, solution residual, inverse, rank, storage conversion, or condition estimate", + "linear_banded_tridiagonal": "reconstructed logical matrix, factor agreement, solution residual, or condition estimate", + "linear_triangular": "triangular residual, inverse identity, condition estimate, or packed/RFP round trip", + "least_squares": "normal-equation residual, rank, singular values, or equality constraint", + "orthogonal_factorizations": "reflector identity, orthogonality, and factorization/application reconstruction", + "eigen_nonsymmetric": "eigen residual, similarity/Schur reconstruction, orthogonality, or Sylvester equation", + "eigen_symmetric": "eigen residual, orthogonality, selected spectrum, or tridiagonal reduction", + "eigen_generalized": "generalized eigen residual, Schur reconstruction, or generalized Sylvester equations", + "svd": "SVD/CSD reconstruction, orthogonality, or secular equation", +} + +F2PY_EXPORT_LIMITATIONS = { + "dgees": "NumPy f2py 2.5.1 generates an incomplete select callback declaration from the unannotated source", + "dgges": "NumPy f2py 2.5.1 generates an incomplete selctg callback declaration from the unannotated source", +} + +PRIK_ABI_ADAPTERS = { + "dtgsen": "GFortran default-LOGICAL selection storage is four bytes per element while PRIK accepts a NumPy bool buffer", + "dtrsen": "GFortran default-LOGICAL selection storage is four bytes per element while PRIK accepts a NumPy bool buffer", +} + + +@dataclass(frozen=True) +class RoutineSpec: + """Reviewed audit metadata for one selected native LAPACK routine.""" + + native_name: str + source_file: str + scipy_name: str + prik_export: str + prik_adapter: str + f2py_export: str + f2py_behavior: str + family: str + mutation: str + returns: str + workspace: str + index_convention: str + oracle: str + test_name: str + + +ROUTINE_SPECS = { + name: RoutineSpec( + native_name=name, + source_file=f"{name}.f90" if name == "dlartg" else f"{name}.f", + scipy_name=name, + prik_export=name, + prik_adapter=PRIK_ABI_ADAPTERS.get(name, "none"), + f2py_export=name, + f2py_behavior=F2PY_EXPORT_LIMITATIONS.get( + name, + ( + "build-local intent directives expose caller-owned scalar writeback storage" + if name in F2PY_SCALAR_WRITEBACK_ROUTINES + else "none" + ), + ), + family=ROUTINE_FAMILIES[name], + mutation="explicit in/out arrays and preserved inputs are asserted in the named test", + returns="PRIK native scalar tuple, SciPy projected tuple, and f2py observable writeback", + workspace=( + "explicit workspace arrays and sizes are visible in the named test" + if name in WORKSPACE_ROUTINES + else "no caller-managed workspace" + ), + index_convention=( + "native PRIK/f2py indexes are one-based; any SciPy conversion is visible in the named test" + if name in INDEX_ROUTINES + else "no pivot or index conversion" + ), + oracle=ORACLE_BY_FAMILY[ROUTINE_FAMILIES[name]], + test_name=EXPLICIT_TEST_NAMES[name], + ) + for name in ROUTINES +} diff --git a/examples/lapack/tests/__init__.py b/examples/lapack/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/examples/lapack/tests/helpers.py b/examples/lapack/tests/helpers.py new file mode 100644 index 000000000..9ff770b52 --- /dev/null +++ b/examples/lapack/tests/helpers.py @@ -0,0 +1,176 @@ +"""Small numerical and storage helpers for the LAPACK correctness example.""" + +from __future__ import annotations + +import numpy as np + + +def assert_allclose_float64(actual, expected, *, operation_size: int = 1) -> None: + """Compare float64 LAPACK results with an accumulation-aware tolerance.""" + scale = max(1, operation_size) + expected_array = np.asarray(expected) + magnitude = max(1.0, float(np.max(np.abs(expected_array), initial=0.0))) + np.testing.assert_allclose( + actual, + expected, + rtol=np.finfo(np.float64).eps * 32 * scale, + atol=np.finfo(np.float64).eps * 32 * scale * magnitude, + ) + + +def assert_info(result, expected: int = 0) -> None: + """Check the trailing LAPACK INFO return value.""" + assert int(np.asarray(result[-1])) == expected + + +def assert_small_residual( + residual, + *, + matrix_norm: float, + solution_norm: float, + operation_size: int, +) -> None: + """Check a backward residual scaled by the represented operation.""" + denominator = max(1.0, matrix_norm * solution_norm) + scaled = np.linalg.norm(np.asarray(residual, dtype=np.float64), ord=np.inf) / denominator + tolerance = np.finfo(np.float64).eps * 128 * max(1, operation_size) + assert scaled <= tolerance, f"scaled residual {scaled} exceeded {tolerance}" + + +def assert_orthogonal(matrix: np.ndarray, *, columns: int | None = None) -> None: + """Validate orthonormal columns without hiding a routine invocation.""" + active_columns = matrix.shape[1] if columns is None else columns + basis = np.asarray(matrix[:, :active_columns], dtype=np.float64) + assert_allclose_float64( + basis.T @ basis, + np.eye(active_columns, dtype=np.float64), + operation_size=basis.shape[0], + ) + + +def native_pivots(scipy_pivots: np.ndarray) -> np.ndarray: + """Convert SciPy's zero-based pivots to LAPACK's native one-based values.""" + return np.asarray(scipy_pivots, dtype=np.int32) + np.int32(1) + + +def gfortran_logical_mask(values) -> np.ndarray: + """Represent a default-GFortran LOGICAL vector through PRIK's bool buffer ABI.""" + logical_bytes = np.zeros(len(values) * np.dtype(np.int32).itemsize, dtype=np.bool_) + logical_bytes[:: np.dtype(np.int32).itemsize] = np.asarray(values, dtype=np.bool_) + return logical_bytes + + +def pivot_matrix(pivots: np.ndarray, size: int, *, one_based: bool) -> np.ndarray: + """Build the row permutation represented by sequential LAPACK pivots.""" + permutation = np.eye(size, dtype=np.float64) + for row, pivot in enumerate(np.asarray(pivots, dtype=np.int64)): + target = int(pivot) - int(one_based) + permutation[[row, target], :] = permutation[[target, row], :] + return permutation + + +def unpack_lu(factor: np.ndarray) -> tuple[np.ndarray, np.ndarray]: + """Split LAPACK's combined LU storage into logical L and U matrices.""" + rows, columns = factor.shape + rank = min(rows, columns) + lower = np.tril(factor[:, :rank], k=-1) + np.eye(rows, rank, dtype=np.float64) + upper = np.triu(factor[:rank, :]) + return lower, upper + + +def qr_q_from_reflectors(factor: np.ndarray, tau: np.ndarray) -> np.ndarray: + """Form reduced Q explicitly from DGEQRF Householder storage.""" + rows, columns = factor.shape + reflectors = min(rows, columns, len(tau)) + q = np.eye(rows, dtype=np.float64) + for index in range(reflectors): + vector = np.zeros(rows, dtype=np.float64) + vector[index] = 1.0 + vector[index + 1 :] = factor[index + 1 :, index] + q = q @ (np.eye(rows, dtype=np.float64) - tau[index] * np.outer(vector, vector)) + return q[:, :columns] + + +def assert_storage_unchanged(actual: np.ndarray, expected: np.ndarray) -> None: + """Compare storage exactly, including NaN sentinels.""" + np.testing.assert_array_equal(actual, expected) + + +def general_band_storage(matrix: np.ndarray, lower: int, upper: int, *, factor: bool = False) -> np.ndarray: + """Pack a square general band matrix in LAPACK column-major storage.""" + logical = np.asarray(matrix, dtype=np.float64) + rows = 2 * lower + upper + 1 if factor else lower + upper + 1 + diagonal_row = lower + upper if factor else upper + band = np.zeros((rows, logical.shape[1]), dtype=np.float64, order="F") + for column in range(logical.shape[1]): + for row in range(max(0, column - upper), min(logical.shape[0], column + lower + 1)): + band[diagonal_row + row - column, column] = logical[row, column] + return band + + +def symmetric_band_storage(matrix: np.ndarray, bandwidth: int, *, lower: bool) -> np.ndarray: + """Pack one triangle of a symmetric band matrix.""" + logical = np.asarray(matrix, dtype=np.float64) + band = np.zeros((bandwidth + 1, logical.shape[1]), dtype=np.float64, order="F") + for column in range(logical.shape[1]): + if lower: + rows = range(column, min(logical.shape[0], column + bandwidth + 1)) + for row in rows: + band[row - column, column] = logical[row, column] + else: + rows = range(max(0, column - bandwidth), column + 1) + for row in rows: + band[bandwidth + row - column, column] = logical[row, column] + return band + + +def packed_symmetric(matrix: np.ndarray, *, lower: bool) -> np.ndarray: + """Pack one triangle in LAPACK packed-column order.""" + logical = np.asarray(matrix, dtype=np.float64) + values: list[float] = [] + for column in range(logical.shape[1]): + rows = range(column, logical.shape[0]) if lower else range(column + 1) + values.extend(float(logical[row, column]) for row in rows) + return np.asarray(values, dtype=np.float64) + + +def unpack_packed_symmetric(values: np.ndarray, size: int, *, lower: bool) -> np.ndarray: + """Reconstruct a symmetric matrix from LAPACK packed-column storage.""" + matrix = np.zeros((size, size), dtype=np.float64) + offset = 0 + for column in range(size): + rows = range(column, size) if lower else range(column + 1) + for row in rows: + matrix[row, column] = values[offset] + matrix[column, row] = values[offset] + offset += 1 + return matrix + + +def tridiagonal_matrix(lower: np.ndarray, diagonal: np.ndarray, upper: np.ndarray) -> np.ndarray: + """Construct the logical matrix represented by three diagonals.""" + return np.diag(diagonal) + np.diag(upper, 1) + np.diag(lower, -1) + + +def column_major(matrix: np.ndarray, *, rows: int | None = None) -> np.ndarray: + """Return a Fortran-contiguous float64 matrix with optional leading padding.""" + array = np.asarray(matrix, dtype=np.float64) + if rows is None or rows == array.shape[0]: + return np.array(array, dtype=np.float64, order="F", copy=True) + padded = np.full((rows, array.shape[1]), np.nan, dtype=np.float64, order="F") + padded[: array.shape[0], :] = array + return padded + + +def active(matrix: np.ndarray, rows: int, columns: int) -> np.ndarray: + """Extract the logical matrix while preserving its column-major convention.""" + return np.asarray(matrix[:rows, :columns], dtype=np.float64) + + +def assert_runtime_smoke(module) -> None: + """Exercise a representative complete-library LAPACK export.""" + index = np.zeros(5, dtype=np.int32) + values = np.array([1.0, 4.0, 7.0, 2.0, 8.0], dtype=np.float64) + scalars = module.dlamrg(np.int32(3), np.int32(2), values, np.int32(1), np.int32(1), index) + assert scalars == (np.int32(3), np.int32(2), np.int32(1), np.int32(1)) + np.testing.assert_array_equal(index, [1, 4, 2, 3, 5]) diff --git a/examples/lapack/tests/test_auxiliary.py b/examples/lapack/tests/test_auxiliary.py new file mode 100644 index 000000000..466571389 --- /dev/null +++ b/examples/lapack/tests/test_auxiliary.py @@ -0,0 +1,165 @@ +"""Auxiliary, norm, reflector, rotation, and permutation correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, column_major, general_band_storage, native_pivots + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dlamch_reports_float64_machine_epsilon(prik_lapack, scipy_lapack, f2py_lapack): + expected = np.finfo(np.float64).eps / 2.0 + + prik_value = prik_lapack.dlamch("E") + f2py_value = f2py_lapack.dlamch(b"E") + scipy_value = scipy_lapack.dlamch(b"E") + + assert_allclose_float64(prik_value, expected) + assert_allclose_float64(f2py_value, expected) + assert_allclose_float64(scipy_value, expected) + + +def test_dlangb_computes_frobenius_norm_of_band_storage(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[2.0, -1.0, 0.0], [3.0, 4.0, 5.0], [0.0, 6.0, -2.0]], dtype=np.float64) + expected = float(np.sqrt(sum(float(value * value) for value in matrix.flat))) + prik_ab = general_band_storage(matrix, 1, 1) + f2py_ab = prik_ab.copy(order="F") + scipy_ab = prik_ab.copy(order="F") + + prik_result = prik_lapack.dlangb( + "F", np.int32(3), np.int32(1), np.int32(1), prik_ab, np.int32(3), np.empty(3, dtype=np.float64) + ) + f2py_value = f2py_lapack.dlangb(b"F", 3, 1, 1, f2py_ab, np.empty(3, dtype=np.float64)) + scipy_value = scipy_lapack.dlangb(b"F", 1, 1, scipy_ab) + + assert prik_result[1:] == (3, 1, 1, 3) + assert_allclose_float64(prik_result[0], expected, operation_size=7) + assert_allclose_float64(f2py_value, expected, operation_size=7) + assert_allclose_float64(scipy_value, expected, operation_size=7) + + +def test_dlange_computes_one_norm(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, -5.0], [3.0, 2.0], [-2.0, 4.0]], dtype=np.float64, order="F") + expected = 11.0 + work = np.empty(3, dtype=np.float64) + + prik_result = prik_lapack.dlange("1", np.int32(3), np.int32(2), matrix.copy(order="F"), np.int32(3), work.copy()) + f2py_value = f2py_lapack.dlange(b"1", 3, 2, matrix.copy(order="F"), work.copy()) + scipy_value = scipy_lapack.dlange(b"1", matrix.copy(order="F")) + + assert prik_result[1:] == (3, 2, 3) + assert_allclose_float64(prik_result[0], expected, operation_size=3) + assert_allclose_float64(f2py_value, expected, operation_size=3) + assert_allclose_float64(scipy_value, expected, operation_size=3) + + +def test_dlantr_ignores_unused_triangle_and_unit_diagonal(prik_lapack, scipy_lapack, f2py_lapack): + stored = np.array([[np.nan, 2.0, -1.0], [np.nan, np.nan, 3.0], [np.nan, np.nan, np.nan]], order="F") + expected = float(np.sqrt(1.0 + 4.0 + 1.0 + 1.0 + 9.0 + 1.0)) + work = np.empty(3, dtype=np.float64) + + prik_result = prik_lapack.dlantr( + "F", "U", "U", np.int32(3), np.int32(3), stored.copy(order="F"), np.int32(3), work.copy() + ) + f2py_value = f2py_lapack.dlantr(b"F", b"U", b"U", 3, 3, stored.copy(order="F"), work.copy()) + scipy_value = scipy_lapack.dlantr(b"F", stored.copy(order="F"), uplo=b"U", diag=b"U") + + assert prik_result[1:] == (3, 3, 3) + assert_allclose_float64(prik_result[0], expected, operation_size=6) + assert_allclose_float64(f2py_value, expected, operation_size=6) + assert_allclose_float64(scipy_value, expected, operation_size=6) + + +def test_dlarf_applies_householder_reflector_from_left(prik_lapack, scipy_lapack, f2py_lapack): + vector = np.array([1.0, 2.0], dtype=np.float64) + tau = 0.4 + original = np.array([[1.0, 3.0], [2.0, -1.0]], dtype=np.float64) + reflector = np.eye(2, dtype=np.float64) - tau * np.outer(vector, vector) + expected = reflector @ original + prik_c, f2py_c = column_major(original), column_major(original) + + prik_scalars = prik_lapack.dlarf( + "L", np.int32(2), np.int32(2), vector, np.int32(1), np.float64(tau), prik_c, np.int32(2), np.empty(2) + ) + f2py_result = f2py_lapack.dlarf(b"L", 2, 2, vector, 1, tau, f2py_c, np.empty(2)) + scipy_c = scipy_lapack.dlarf(vector, tau, original.copy(order="F"), np.empty(2), side=b"L") + + assert prik_scalars == (2, 2, 1, tau, 2) + assert f2py_result is None + assert_allclose_float64(prik_c, expected, operation_size=2) + assert_allclose_float64(f2py_c, expected, operation_size=2) + assert_allclose_float64(scipy_c, expected, operation_size=2) + + +def test_dlarfg_constructs_a_valid_householder_reflector(prik_lapack, scipy_lapack, f2py_lapack): + alpha = 4.0 + original_x = np.array([3.0, 0.0], dtype=np.float64) + prik_x, f2py_x = original_x.copy(), original_x.copy() + f2py_alpha = np.array(alpha, dtype=np.float64) + f2py_tau = np.array(0.0, dtype=np.float64) + + prik_scalars = prik_lapack.dlarfg(np.int32(3), np.float64(alpha), prik_x, np.int32(1), np.float64(0.0)) + f2py_result = f2py_lapack.dlarfg(3, f2py_alpha, f2py_x, 1, f2py_tau) + scipy_beta, scipy_x, scipy_tau = scipy_lapack.dlarfg(3, alpha, original_x.copy()) + + _, prik_beta, _, prik_tau = prik_scalars + prik_vector = np.concatenate(([1.0], prik_x)) + f2py_vector = np.concatenate(([1.0], f2py_x)) + original = np.concatenate(([alpha], original_x)) + prik_expected = np.array([prik_beta, 0.0, 0.0], dtype=np.float64) + f2py_expected = np.array([f2py_alpha, 0.0, 0.0], dtype=np.float64) + assert f2py_result is None + assert_allclose_float64((np.eye(3) - prik_tau * np.outer(prik_vector, prik_vector)) @ original, prik_expected) + assert_allclose_float64((np.eye(3) - f2py_tau * np.outer(f2py_vector, f2py_vector)) @ original, f2py_expected) + assert_allclose_float64(prik_beta, scipy_beta) + assert_allclose_float64(f2py_alpha, scipy_beta) + assert_allclose_float64(prik_x, scipy_x) + assert_allclose_float64(f2py_x, scipy_x) + assert_allclose_float64(prik_tau, scipy_tau) + assert_allclose_float64(f2py_tau, scipy_tau) + + +def test_dlartg_constructs_a_givens_rotation(prik_lapack, scipy_lapack, f2py_lapack): + f, g = 3.0, 4.0 + f2py_c = np.array(0.0, dtype=np.float64) + f2py_s = np.array(0.0, dtype=np.float64) + f2py_r = np.array(0.0, dtype=np.float64) + + prik_scalars = prik_lapack.dlartg(np.float64(f), np.float64(g), np.float64(0.0), np.float64(0.0), np.float64(0.0)) + f2py_result = f2py_lapack.dlartg(f, g, f2py_c, f2py_s, f2py_r) + scipy_c, scipy_s, scipy_r = scipy_lapack.dlartg(f, g) + + _, _, prik_c, prik_s, prik_r = prik_scalars + assert f2py_result is None + assert_allclose_float64(prik_c * f + prik_s * g, prik_r) + assert_allclose_float64(-prik_s * f + prik_c * g, 0.0) + assert_allclose_float64(prik_c * prik_c + prik_s * prik_s, 1.0) + assert_allclose_float64([prik_c, prik_s, prik_r], [scipy_c, scipy_s, scipy_r]) + assert_allclose_float64(f2py_c * f + f2py_s * g, f2py_r) + assert_allclose_float64(-f2py_s * f + f2py_c * g, 0.0) + assert_allclose_float64(f2py_c * f2py_c + f2py_s * f2py_s, 1.0) + assert_allclose_float64([f2py_c, f2py_s, f2py_r], [scipy_c, scipy_s, scipy_r]) + + +def test_dlaswp_applies_native_one_based_row_pivots(prik_lapack, scipy_lapack, f2py_lapack): + original = np.array([[1.0, 10.0], [2.0, 20.0], [3.0, 30.0]], dtype=np.float64) + scipy_pivots = np.array([2, 2], dtype=np.int32) + native_ipiv = native_pivots(scipy_pivots) + expected = original[[2, 0, 1], :] + prik_a, f2py_a = column_major(original), column_major(original) + + prik_scalars = prik_lapack.dlaswp( + np.int32(2), prik_a, np.int32(3), np.int32(1), np.int32(2), native_ipiv, np.int32(1) + ) + f2py_result = f2py_lapack.dlaswp(2, f2py_a, 1, 2, native_ipiv, 1) + scipy_a = scipy_lapack.dlaswp(original.copy(order="F"), scipy_pivots, k1=0, k2=1) + + assert prik_scalars == (2, 3, 1, 2, 1) + assert f2py_result is None + assert_allclose_float64(prik_a, expected) + assert_allclose_float64(f2py_a, expected) + assert_allclose_float64(scipy_a, expected) diff --git a/examples/lapack/tests/test_eigen_generalized.py b/examples/lapack/tests/test_eigen_generalized.py new file mode 100644 index 000000000..714e99517 --- /dev/null +++ b/examples/lapack/tests/test_eigen_generalized.py @@ -0,0 +1,482 @@ +"""Generalized nonsymmetric and symmetric eigenvalue correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_orthogonal, gfortran_logical_mask + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def _generalized_problem(): + a = np.diag([2.0, 6.0]).astype(np.float64, order="F") + b = np.diag([1.0, 2.0]).astype(np.float64, order="F") + return a, b + + +def _assert_generalized_eigenpairs(a, b, values, vectors): + assert_allclose_float64(values, [2.0, 3.0]) + for index in range(2): + assert_allclose_float64(a @ vectors[:, index], values[index] * (b @ vectors[:, index]), operation_size=2) + assert_allclose_float64(vectors.T @ b @ vectors, np.eye(2), operation_size=2) + + +def test_dgges_computes_generalized_real_schur_form(prik_lapack, scipy_lapack): + original_a, original_b = _generalized_problem() + prik_a = original_a.copy(order="F") + prik_b = original_b.copy(order="F") + prik_ar, prik_ai, prik_beta = np.empty(2), np.empty(2), np.empty(2) + prik_vsl, prik_vsr = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dgges( + "V", + "V", + "N", + np.bool_(False), + np.int32(2), + prik_a, + np.int32(2), + prik_b, + np.int32(2), + np.int32(0), + prik_ar, + prik_ai, + prik_beta, + prik_vsl, + np.int32(2), + prik_vsr, + np.int32(2), + np.empty(64), + np.int32(64), + np.zeros(2, dtype=np.bool_), + np.int32(0), + ) + scipy_a, scipy_b, scipy_sdim, scipy_ar, scipy_ai, scipy_beta, scipy_vsl, scipy_vsr, _work, scipy_info = ( + scipy_lapack.dgges( + lambda _ar, _ai, _beta: 0, + original_a.copy(order="F"), + original_b.copy(order="F"), + jobvsl=1, + jobvsr=1, + sort_t=0, + lwork=64, + ) + ) + + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[4] == scipy_sdim == 0 + for s, t, ar, ai, beta, q, z in ( + (prik_a, prik_b, prik_ar, prik_ai, prik_beta, prik_vsl, prik_vsr), + (scipy_a, scipy_b, scipy_ar, scipy_ai, scipy_beta, scipy_vsl, scipy_vsr), + ): + assert_orthogonal(q) + assert_orthogonal(z) + assert_allclose_float64(q @ s @ z.T, original_a, operation_size=2) + assert_allclose_float64(q @ t @ z.T, original_b, operation_size=2) + assert_allclose_float64(ai, [0.0, 0.0]) + assert_allclose_float64(ar / beta, [2.0, 3.0]) + + +def test_dggev_computes_generalized_right_eigenvectors(prik_lapack, scipy_lapack, f2py_lapack): + a, b = _generalized_problem() + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_ar, prik_ai, prik_beta = np.empty(2), np.empty(2), np.empty(2) + f2py_ar, f2py_ai, f2py_beta = np.empty(2), np.empty(2), np.empty(2) + prik_vl, prik_vr = np.empty((1, 2), order="F"), np.empty((2, 2), order="F") + f2py_vl, f2py_vr = np.empty((1, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dggev( + "N", + "V", + np.int32(2), + prik_a, + np.int32(2), + prik_b, + np.int32(2), + prik_ar, + prik_ai, + prik_beta, + prik_vl, + np.int32(1), + prik_vr, + np.int32(2), + np.empty(64), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dggev( + b"N", b"V", 2, f2py_a, f2py_b, f2py_ar, f2py_ai, f2py_beta, f2py_vl, f2py_vr, np.empty(64), 64, 0 + ) + scipy_ar, scipy_ai, scipy_beta, _vl, scipy_vr, _work, scipy_info = scipy_lapack.dggev( + a.copy(order="F"), b.copy(order="F"), compute_vl=0, compute_vr=1, lwork=64 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for ar, ai, beta, vr in ( + (prik_ar, prik_ai, prik_beta, prik_vr), + (f2py_ar, f2py_ai, f2py_beta, f2py_vr), + (scipy_ar, scipy_ai, scipy_beta, scipy_vr), + ): + assert_allclose_float64(ai, [0.0, 0.0]) + for index in range(2): + assert_allclose_float64(beta[index] * (a @ vr[:, index]), ar[index] * (b @ vr[:, index]), operation_size=2) + + +def test_dsygst_reduces_symmetric_generalized_problem(prik_lapack, scipy_lapack, f2py_lapack): + a, _b = _generalized_problem() + cholesky = np.diag([1.0, np.sqrt(2.0)]).astype(np.float64, order="F") + expected = np.diag([2.0, 3.0]) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + + prik_scalars = prik_lapack.dsygst( + np.int32(1), "U", np.int32(2), prik_a, np.int32(2), cholesky, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dsygst(1, b"U", 2, f2py_a, cholesky, 0) + scipy_a, scipy_info = scipy_lapack.dsygst(a.copy(order="F"), cholesky, itype=1, lower=0) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, expected, operation_size=2) + assert_allclose_float64(f2py_a, expected, operation_size=2) + assert_allclose_float64(scipy_a, expected, operation_size=2) + assert_allclose_float64(np.linalg.inv(cholesky.T) @ a @ np.linalg.inv(cholesky), expected, operation_size=2) + + +def test_dsygv_solves_symmetric_generalized_eigenproblem(prik_lapack, scipy_lapack, f2py_lapack): + a, b = _generalized_problem() + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dsygv( + np.int32(1), + "V", + "U", + np.int32(2), + prik_a, + np.int32(2), + prik_b, + np.int32(2), + prik_w, + np.empty(64), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dsygv(1, b"V", b"U", 2, f2py_a, f2py_b, f2py_w, np.empty(64), 64, 0) + scipy_w, scipy_v, scipy_info = scipy_lapack.dsygv( + a.copy(order="F"), b.copy(order="F"), itype=1, jobz=b"V", uplo=b"U", lwork=64 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_generalized_eigenpairs(a, b, prik_w, prik_a) + _assert_generalized_eigenpairs(a, b, f2py_w, f2py_a) + _assert_generalized_eigenpairs(a, b, scipy_w, scipy_v) + + +def test_dsygvd_solves_divide_and_conquer_generalized_problem(prik_lapack, scipy_lapack, f2py_lapack): + a, b = _generalized_problem() + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dsygvd( + np.int32(1), + "V", + "U", + np.int32(2), + prik_a, + np.int32(2), + prik_b, + np.int32(2), + prik_w, + np.empty(64), + np.int32(64), + np.empty(32, dtype=np.int32), + np.int32(32), + np.int32(0), + ) + f2py_result = f2py_lapack.dsygvd( + 1, b"V", b"U", 2, f2py_a, f2py_b, f2py_w, np.empty(64), 64, np.empty(32, dtype=np.int32), 32, 0 + ) + scipy_w, scipy_v, scipy_info = scipy_lapack.dsygvd( + a.copy(order="F"), b.copy(order="F"), itype=1, jobz=b"V", uplo=b"U", lwork=64, liwork=32 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_generalized_eigenpairs(a, b, prik_w, prik_a) + _assert_generalized_eigenpairs(a, b, f2py_w, f2py_a) + _assert_generalized_eigenpairs(a, b, scipy_w, scipy_v) + + +def test_dsygvx_selects_generalized_eigenpairs(prik_lapack, scipy_lapack, f2py_lapack): + a, b = _generalized_problem() + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + prik_ifail, f2py_ifail = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dsygvx( + np.int32(1), + "V", + "I", + "U", + np.int32(2), + prik_a, + np.int32(2), + prik_b, + np.int32(2), + np.float64(0.0), + np.float64(0.0), + np.int32(1), + np.int32(2), + np.float64(0.0), + np.int32(0), + prik_w, + prik_z, + np.int32(2), + np.empty(64), + np.int32(64), + np.empty(10, dtype=np.int32), + prik_ifail, + np.int32(0), + ) + f2py_result = f2py_lapack.dsygvx( + 1, + b"V", + b"I", + b"U", + 2, + f2py_a, + f2py_b, + 0.0, + 0.0, + 1, + 2, + 0.0, + 0, + f2py_w, + f2py_z, + np.empty(64), + 64, + np.empty(10, dtype=np.int32), + f2py_ifail, + 0, + ) + scipy_w, scipy_z, scipy_m, scipy_ifail, scipy_info = scipy_lapack.dsygvx( + a.copy(order="F"), b.copy(order="F"), itype=1, jobz=b"V", range=b"I", uplo=b"U", il=1, iu=2, lwork=64 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[9] == scipy_m == 2 + _assert_generalized_eigenpairs(a, b, prik_w, prik_z) + _assert_generalized_eigenpairs(a, b, f2py_w, f2py_z) + _assert_generalized_eigenpairs(a, b, scipy_w, scipy_z) + np.testing.assert_array_equal(prik_ifail, scipy_ifail) + np.testing.assert_array_equal(f2py_ifail, scipy_ifail) + + +def test_dtgexc_reorders_generalized_schur_blocks(prik_lapack, scipy_lapack, f2py_lapack): + a, b = _generalized_problem() + identity = np.eye(2, dtype=np.float64, order="F") + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_q, f2py_q = identity.copy(order="F"), identity.copy(order="F") + prik_z, f2py_z = identity.copy(order="F"), identity.copy(order="F") + + prik_scalars = prik_lapack.dtgexc( + np.bool_(True), + np.bool_(True), + np.int32(2), + prik_a, + np.int32(2), + prik_b, + np.int32(2), + prik_q, + np.int32(2), + prik_z, + np.int32(2), + np.int32(1), + np.int32(2), + np.empty(64), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dtgexc(1, 1, 2, f2py_a, f2py_b, f2py_q, f2py_z, 1, 2, np.empty(64), 64, 0) + scipy_a, scipy_b, scipy_q, scipy_z, _work, scipy_info = scipy_lapack.dtgexc( + a.copy(order="F"), + b.copy(order="F"), + identity.copy(order="F"), + identity.copy(order="F"), + 1, + 2, + wantq=1, + wantz=1, + lwork=64, + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for s, t, q, z in ( + (prik_a, prik_b, prik_q, prik_z), + (f2py_a, f2py_b, f2py_q, f2py_z), + (scipy_a, scipy_b, scipy_q, scipy_z), + ): + assert_allclose_float64(np.diag(s) / np.diag(t), [3.0, 2.0]) + assert_allclose_float64(q @ s @ z.T, a, operation_size=2) + assert_allclose_float64(q @ t @ z.T, b, operation_size=2) + + +def test_dtgsen_reorders_selected_generalized_eigenvalue(prik_lapack, scipy_lapack, f2py_lapack): + a, b = _generalized_problem() + identity = np.eye(2, dtype=np.float64, order="F") + selection = np.array([False, True], dtype=np.bool_) + prik_selection = gfortran_logical_mask(selection) + prik_a, f2py_a = a.copy(order="F"), a.copy(order="F") + prik_b, f2py_b = b.copy(order="F"), b.copy(order="F") + prik_q, f2py_q = identity.copy(order="F"), identity.copy(order="F") + prik_z, f2py_z = identity.copy(order="F"), identity.copy(order="F") + prik_ar, prik_ai, prik_beta = np.empty(2), np.empty(2), np.empty(2) + f2py_ar, f2py_ai, f2py_beta = np.empty(2), np.empty(2), np.empty(2) + prik_dif, f2py_dif = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dtgsen( + np.int32(0), + np.bool_(True), + np.bool_(True), + prik_selection, + np.int32(2), + prik_a, + np.int32(2), + prik_b, + np.int32(2), + prik_ar, + prik_ai, + prik_beta, + prik_q, + np.int32(2), + prik_z, + np.int32(2), + np.int32(0), + np.float64(0.0), + np.float64(0.0), + prik_dif, + np.empty(64), + np.int32(64), + np.empty(16, dtype=np.int32), + np.int32(16), + np.int32(0), + ) + f2py_result = f2py_lapack.dtgsen( + 0, + 1, + 1, + selection.astype(np.int32), + 2, + f2py_a, + f2py_b, + f2py_ar, + f2py_ai, + f2py_beta, + f2py_q, + f2py_z, + 0, + 0.0, + 0.0, + f2py_dif, + np.empty(64), + 64, + np.empty(16, dtype=np.int32), + 16, + 0, + ) + scipy_a, scipy_b, scipy_ar, scipy_ai, scipy_beta, scipy_q, scipy_z, scipy_m, _pl, _pr, _dif, scipy_info = ( + scipy_lapack.dtgsen( + selection.astype(np.int32), + a.copy(order="F"), + b.copy(order="F"), + identity.copy(order="F"), + identity.copy(order="F"), + ijob=0, + wantq=1, + wantz=1, + lwork=64, + liwork=16, + ) + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[8] == scipy_m == 1 + for s, t, ar, ai, beta, q, z in ( + (prik_a, prik_b, prik_ar, prik_ai, prik_beta, prik_q, prik_z), + (f2py_a, f2py_b, f2py_ar, f2py_ai, f2py_beta, f2py_q, f2py_z), + (scipy_a, scipy_b, scipy_ar, scipy_ai, scipy_beta, scipy_q, scipy_z), + ): + assert_allclose_float64(ai, [0.0, 0.0]) + assert_allclose_float64(ar / beta, [3.0, 2.0]) + assert_allclose_float64(q @ s @ z.T, a, operation_size=2) + assert_allclose_float64(q @ t @ z.T, b, operation_size=2) + + +def test_dtgsyl_solves_generalized_sylvester_equations(prik_lapack, scipy_lapack, f2py_lapack): + a = np.array([[2.0]], dtype=np.float64, order="F") + b = np.array([[3.0]], dtype=np.float64, order="F") + c = np.array([[-4.0]], dtype=np.float64, order="F") + d = np.array([[1.0]], dtype=np.float64, order="F") + e = np.array([[4.0]], dtype=np.float64, order="F") + f = np.array([[-7.0]], dtype=np.float64, order="F") + prik_c, f2py_c = c.copy(order="F"), c.copy(order="F") + prik_f, f2py_f = f.copy(order="F"), f.copy(order="F") + + prik_scalars = prik_lapack.dtgsyl( + "N", + np.int32(0), + np.int32(1), + np.int32(1), + a, + np.int32(1), + b, + np.int32(1), + prik_c, + np.int32(1), + d, + np.int32(1), + e, + np.int32(1), + prik_f, + np.int32(1), + np.float64(0.0), + np.float64(0.0), + np.empty(8), + np.int32(8), + np.empty(2, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dtgsyl( + b"N", 0, 1, 1, a, b, f2py_c, d, e, f2py_f, 0.0, 0.0, np.empty(8), 8, np.empty(2, dtype=np.int32), 0 + ) + scipy_r, scipy_l, scipy_scale, scipy_dif, scipy_info = scipy_lapack.dtgsyl( + a, b, c.copy(order="F"), d, e, f.copy(order="F"), trans=b"N", ijob=0, lwork=8 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_c, [[1.0]]) + assert_allclose_float64(f2py_c, [[1.0]]) + assert_allclose_float64(scipy_r, [[1.0]]) + assert_allclose_float64(prik_f, [[2.0]]) + assert_allclose_float64(f2py_f, [[2.0]]) + assert_allclose_float64(scipy_l, [[2.0]]) + assert_allclose_float64(a @ prik_c - prik_f @ b, prik_scalars[-4] * c) + assert_allclose_float64(d @ prik_c - prik_f @ e, prik_scalars[-4] * f) + assert_allclose_float64(prik_scalars[-4], scipy_scale) + assert_allclose_float64(prik_scalars[-3], scipy_dif) diff --git a/examples/lapack/tests/test_eigen_nonsymmetric.py b/examples/lapack/tests/test_eigen_nonsymmetric.py new file mode 100644 index 000000000..c7467474d --- /dev/null +++ b/examples/lapack/tests/test_eigen_nonsymmetric.py @@ -0,0 +1,275 @@ +"""Nonsymmetric eigenvalue, Schur, Hessenberg, and Sylvester correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_orthogonal, gfortran_logical_mask + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dgebal_preserves_eigenvalues_while_balancing(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.diag(np.array([2.0, 5.0], dtype=np.float64)).copy(order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_scale, f2py_scale = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dgebal( + "B", np.int32(2), prik_a, np.int32(2), np.int32(0), np.int32(0), prik_scale, np.int32(0) + ) + f2py_result = f2py_lapack.dgebal(b"B", 2, f2py_a, 0, 0, f2py_scale, 0) + scipy_a, scipy_lo, scipy_hi, scipy_scale, scipy_info = scipy_lapack.dgebal( + matrix.copy(order="F"), scale=1, permute=1 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[2:4] == (scipy_lo + 1, scipy_hi + 1) + assert_allclose_float64(np.sort(np.diag(prik_a)), [2.0, 5.0]) + assert_allclose_float64(np.sort(np.diag(f2py_a)), [2.0, 5.0]) + assert_allclose_float64(prik_a, scipy_a) + assert_allclose_float64(f2py_a, scipy_a) + assert_allclose_float64(prik_scale, scipy_scale) + assert_allclose_float64(f2py_scale, scipy_scale) + + +def test_dgees_computes_real_schur_decomposition(prik_lapack, scipy_lapack): + matrix = np.array([[1.0, 2.0], [0.0, 3.0]], dtype=np.float64, order="F") + prik_t = matrix.copy(order="F") + prik_wr, prik_wi = np.empty(2), np.empty(2) + prik_vs = np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dgees( + "V", + "N", + np.bool_(False), + np.int32(2), + prik_t, + np.int32(2), + np.int32(0), + prik_wr, + prik_wi, + prik_vs, + np.int32(2), + np.empty(64), + np.int32(64), + np.zeros(2, dtype=np.bool_), + np.int32(0), + ) + scipy_t, scipy_sdim, scipy_wr, scipy_wi, scipy_vs, _work, scipy_info = scipy_lapack.dgees( + lambda _wr, _wi: 0, matrix.copy(order="F"), compute_v=1, sort_t=0, lwork=64 + ) + + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[3] == scipy_sdim == 0 + for t, vs, wr, wi in ( + (prik_t, prik_vs, prik_wr, prik_wi), + (scipy_t, scipy_vs, scipy_wr, scipy_wi), + ): + assert_orthogonal(vs) + assert_allclose_float64(vs @ t @ vs.T, matrix, operation_size=2) + assert_allclose_float64(np.sort(wr), [1.0, 3.0]) + assert_allclose_float64(wi, [0.0, 0.0]) + + +def test_dgeev_returns_right_eigenvectors(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [0.0, 3.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_wr, prik_wi = np.empty(2), np.empty(2) + f2py_wr, f2py_wi = np.empty(2), np.empty(2) + prik_vl, prik_vr = np.empty((1, 2), order="F"), np.empty((2, 2), order="F") + f2py_vl, f2py_vr = np.empty((1, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dgeev( + "N", + "V", + np.int32(2), + prik_a, + np.int32(2), + prik_wr, + prik_wi, + prik_vl, + np.int32(1), + prik_vr, + np.int32(2), + np.empty(64), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dgeev(b"N", b"V", 2, f2py_a, f2py_wr, f2py_wi, f2py_vl, f2py_vr, np.empty(64), 64, 0) + scipy_wr, scipy_wi, _vl, scipy_vr, scipy_info = scipy_lapack.dgeev( + matrix.copy(order="F"), compute_vl=0, compute_vr=1, lwork=64 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for wr, wi, vr in ((prik_wr, prik_wi, prik_vr), (f2py_wr, f2py_wi, f2py_vr), (scipy_wr, scipy_wi, scipy_vr)): + assert_allclose_float64(wi, [0.0, 0.0]) + for index in range(2): + assert_allclose_float64(matrix @ vr[:, index], wr[index] * vr[:, index], operation_size=2) + + +def test_dgehrd_reduces_matrix_to_upper_hessenberg(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_tau, f2py_tau = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dgehrd( + np.int32(2), np.int32(1), np.int32(2), prik_a, np.int32(2), prik_tau, np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dgehrd(2, 1, 2, f2py_a, f2py_tau, np.empty(64), 64, 0) + scipy_a, scipy_tau, scipy_info = scipy_lapack.dgehrd(matrix.copy(order="F"), lo=0, hi=1, lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(np.triu(prik_a, -1), matrix) + assert_allclose_float64(np.triu(f2py_a, -1), matrix) + assert_allclose_float64(prik_a, scipy_a) + assert_allclose_float64(f2py_a, scipy_a) + assert_allclose_float64(prik_tau, scipy_tau) + assert_allclose_float64(f2py_tau, scipy_tau) + + +def test_dorghr_forms_hessenberg_similarity_transform(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [3.0, 4.0]], dtype=np.float64, order="F") + factor, tau, factor_info = scipy_lapack.dgehrd(matrix.copy(order="F"), lo=0, hi=1, lwork=64) + assert factor_info == 0 + prik_q, f2py_q = factor.copy(order="F"), factor.copy(order="F") + + prik_scalars = prik_lapack.dorghr( + np.int32(2), np.int32(1), np.int32(2), prik_q, np.int32(2), tau, np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dorghr(2, 1, 2, f2py_q, tau, np.empty(64), 64, 0) + scipy_q, scipy_info = scipy_lapack.dorghr(factor.copy(order="F"), tau, lo=0, hi=1, lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for q in (prik_q, f2py_q, scipy_q): + assert_orthogonal(q) + assert_allclose_float64(q.T @ matrix @ q, matrix, operation_size=2) + + +def test_dtrexc_reorders_real_schur_blocks(prik_lapack, scipy_lapack, f2py_lapack): + schur = np.diag([1.0, 2.0]).astype(np.float64, order="F") + identity = np.eye(2, dtype=np.float64, order="F") + prik_t, f2py_t = schur.copy(order="F"), schur.copy(order="F") + prik_q, f2py_q = identity.copy(order="F"), identity.copy(order="F") + + prik_scalars = prik_lapack.dtrexc( + "V", np.int32(2), prik_t, np.int32(2), prik_q, np.int32(2), np.int32(1), np.int32(2), np.empty(2), np.int32(0) + ) + f2py_result = f2py_lapack.dtrexc(b"V", 2, f2py_t, f2py_q, 1, 2, np.empty(2), 0) + scipy_t, scipy_q, scipy_info = scipy_lapack.dtrexc(schur.copy(order="F"), identity.copy(order="F"), 1, 2, wantq=1) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for t, q in ((prik_t, prik_q), (f2py_t, f2py_q), (scipy_t, scipy_q)): + assert_allclose_float64(np.diag(t), [2.0, 1.0]) + assert_orthogonal(q) + assert_allclose_float64(q @ t @ q.T, schur, operation_size=2) + + +def test_dtrsen_reorders_selected_schur_eigenvalue(prik_lapack, scipy_lapack, f2py_lapack): + schur = np.diag([1.0, 2.0]).astype(np.float64, order="F") + identity = np.eye(2, dtype=np.float64, order="F") + prik_t, f2py_t = schur.copy(order="F"), schur.copy(order="F") + prik_q, f2py_q = identity.copy(order="F"), identity.copy(order="F") + prik_wr, prik_wi = np.empty(2), np.empty(2) + f2py_wr, f2py_wi = np.empty(2), np.empty(2) + selection = np.array([False, True], dtype=np.bool_) + prik_selection = gfortran_logical_mask(selection) + + prik_scalars = prik_lapack.dtrsen( + "N", + "V", + prik_selection, + np.int32(2), + prik_t, + np.int32(2), + prik_q, + np.int32(2), + prik_wr, + prik_wi, + np.int32(0), + np.float64(0.0), + np.float64(0.0), + np.empty(8), + np.int32(8), + np.empty(2, dtype=np.int32), + np.int32(2), + np.int32(0), + ) + f2py_result = f2py_lapack.dtrsen( + b"N", + b"V", + selection.astype(np.int32), + 2, + f2py_t, + f2py_q, + f2py_wr, + f2py_wi, + 0, + 0.0, + 0.0, + np.empty(8), + 8, + np.empty(2, dtype=np.int32), + 2, + 0, + ) + scipy_t, scipy_q, scipy_wr, scipy_wi, scipy_m, _s, _sep, scipy_info = scipy_lapack.dtrsen( + selection.astype(np.int32), + schur.copy(order="F"), + identity.copy(order="F"), + job=b"N", + wantq=1, + lwork=8, + liwork=2, + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[3] == scipy_m == 1 + for t, q, wr, wi in ( + (prik_t, prik_q, prik_wr, prik_wi), + (f2py_t, f2py_q, f2py_wr, f2py_wi), + (scipy_t, scipy_q, scipy_wr, scipy_wi), + ): + assert_allclose_float64(wr, [2.0, 1.0]) + assert_allclose_float64(wi, [0.0, 0.0]) + assert_allclose_float64(q @ t @ q.T, schur, operation_size=2) + + +def test_dtrsyl_solves_sylvester_equation(prik_lapack, scipy_lapack, f2py_lapack): + a = np.array([[2.0]], dtype=np.float64, order="F") + b = np.array([[3.0]], dtype=np.float64, order="F") + c = np.array([[10.0]], dtype=np.float64, order="F") + prik_c, f2py_c = c.copy(order="F"), c.copy(order="F") + + prik_scalars = prik_lapack.dtrsyl( + "N", + "N", + np.int32(1), + np.int32(1), + np.int32(1), + a, + np.int32(1), + b, + np.int32(1), + prik_c, + np.int32(1), + np.float64(0.0), + np.int32(0), + ) + f2py_result = f2py_lapack.dtrsyl(b"N", b"N", 1, 1, 1, a, b, f2py_c, 0.0, 0) + scipy_x, scipy_scale, scipy_info = scipy_lapack.dtrsyl(a, b, c.copy(order="F"), trana=b"N", tranb=b"N", isgn=1) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_c, [[2.0]]) + assert_allclose_float64(f2py_c, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + assert_allclose_float64(prik_scalars[-2], scipy_scale) + assert_allclose_float64(a @ prik_c + prik_c @ b, prik_scalars[-2] * c) diff --git a/examples/lapack/tests/test_eigen_symmetric.py b/examples/lapack/tests/test_eigen_symmetric.py new file mode 100644 index 000000000..1fde5d207 --- /dev/null +++ b/examples/lapack/tests/test_eigen_symmetric.py @@ -0,0 +1,613 @@ +"""Symmetric and tridiagonal eigenvalue correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_orthogonal, column_major, symmetric_band_storage + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def _diagonal_problem(): + matrix = np.diag([2.0, 3.0]).astype(np.float64, order="F") + diagonal = np.array([2.0, 3.0], dtype=np.float64) + offdiag = np.array([0.0], dtype=np.float64) + return matrix, diagonal, offdiag + + +def _assert_eigensystem(matrix, values, vectors): + assert_allclose_float64(values, [2.0, 3.0]) + assert_orthogonal(vectors) + assert_allclose_float64(matrix @ vectors, vectors @ np.diag(values), operation_size=2) + + +def test_dpteqr_diagonalizes_positive_definite_tridiagonal(prik_lapack, scipy_lapack, f2py_lapack): + matrix, diagonal, offdiag = _diagonal_problem() + prik_d, f2py_d = diagonal.copy(), diagonal.copy() + prik_e, f2py_e = offdiag.copy(), offdiag.copy() + prik_z, f2py_z = np.eye(2, dtype=np.float64, order="F"), np.eye(2, dtype=np.float64, order="F") + + prik_scalars = prik_lapack.dpteqr("I", np.int32(2), prik_d, prik_e, prik_z, np.int32(2), np.empty(8), np.int32(0)) + f2py_result = f2py_lapack.dpteqr(b"I", 2, f2py_d, f2py_e, f2py_z, np.empty(8), 0) + scipy_d, _scipy_e, scipy_z, scipy_info = scipy_lapack.dpteqr(diagonal, offdiag, np.eye(2, order="F"), compute_z=1) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + # DPTEQR's contract returns eigenvalues (and matching vectors) in descending order. + _assert_eigensystem(matrix, prik_d[::-1], prik_z[:, ::-1]) + _assert_eigensystem(matrix, f2py_d[::-1], f2py_z[:, ::-1]) + _assert_eigensystem(matrix, scipy_d[::-1], scipy_z[:, ::-1]) + + +def test_dsbev_diagonalizes_symmetric_band_matrix(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _diagonal, _offdiag = _diagonal_problem() + band = symmetric_band_storage(matrix, 1, lower=False) + prik_ab, f2py_ab = band.copy(order="F"), band.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dsbev( + "V", "U", np.int32(2), np.int32(1), prik_ab, np.int32(2), prik_w, prik_z, np.int32(2), np.empty(6), np.int32(0) + ) + f2py_result = f2py_lapack.dsbev(b"V", b"U", 2, 1, f2py_ab, f2py_w, f2py_z, np.empty(6), 0) + scipy_w, scipy_z, scipy_info = scipy_lapack.dsbev(band.copy(order="F"), compute_v=1, lower=0) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_eigensystem(matrix, prik_w, prik_z) + _assert_eigensystem(matrix, f2py_w, f2py_z) + _assert_eigensystem(matrix, scipy_w, scipy_z) + + +def test_dsbevd_diagonalizes_band_matrix_by_divide_and_conquer(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _diagonal, _offdiag = _diagonal_problem() + band = symmetric_band_storage(matrix, 1, lower=False) + prik_ab, f2py_ab = band.copy(order="F"), band.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dsbevd( + "V", + "U", + np.int32(2), + np.int32(1), + prik_ab, + np.int32(2), + prik_w, + prik_z, + np.int32(2), + np.empty(64), + np.int32(64), + np.empty(32, dtype=np.int32), + np.int32(32), + np.int32(0), + ) + f2py_result = f2py_lapack.dsbevd( + b"V", b"U", 2, 1, f2py_ab, f2py_w, f2py_z, np.empty(64), 64, np.empty(32, dtype=np.int32), 32, 0 + ) + scipy_w, scipy_z, scipy_info = scipy_lapack.dsbevd(band.copy(order="F"), compute_v=1, lower=0, liwork=32) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_eigensystem(matrix, prik_w, prik_z) + _assert_eigensystem(matrix, f2py_w, f2py_z) + _assert_eigensystem(matrix, scipy_w, scipy_z) + + +def test_dsbevx_selects_all_symmetric_band_eigenpairs(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _diagonal, _offdiag = _diagonal_problem() + band = symmetric_band_storage(matrix, 1, lower=False) + prik_ab, f2py_ab = band.copy(order="F"), band.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + prik_ifail, f2py_ifail = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dsbevx( + "V", + "A", + "U", + np.int32(2), + np.int32(1), + prik_ab, + np.int32(2), + np.empty((2, 2), order="F"), + np.int32(2), + np.float64(0.0), + np.float64(0.0), + np.int32(1), + np.int32(2), + np.float64(0.0), + np.int32(0), + prik_w, + prik_z, + np.int32(2), + np.empty(14), + np.empty(10, dtype=np.int32), + prik_ifail, + np.int32(0), + ) + f2py_result = f2py_lapack.dsbevx( + b"V", + b"A", + b"U", + 2, + 1, + f2py_ab, + np.empty((2, 2), order="F"), + 0.0, + 0.0, + 1, + 2, + 0.0, + 0, + f2py_w, + f2py_z, + np.empty(14), + np.empty(10, dtype=np.int32), + f2py_ifail, + 0, + ) + scipy_w, scipy_z, scipy_m, scipy_ifail, scipy_info = scipy_lapack.dsbevx( + band.copy(order="F"), 0.0, 0.0, 1, 2, compute_v=1, range=0, lower=0, mmax=2 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[10] == scipy_m == 2 + _assert_eigensystem(matrix, prik_w, prik_z) + _assert_eigensystem(matrix, f2py_w, f2py_z) + _assert_eigensystem(matrix, scipy_w, scipy_z) + np.testing.assert_array_equal(prik_ifail, scipy_ifail) + np.testing.assert_array_equal(f2py_ifail, scipy_ifail) + + +def test_dstebz_bisects_tridiagonal_eigenvalues(prik_lapack, scipy_lapack, f2py_lapack): + _matrix, diagonal, offdiag = _diagonal_problem() + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_iblock, f2py_iblock = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + prik_isplit, f2py_isplit = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dstebz( + "A", + "E", + np.int32(2), + np.float64(0.0), + np.float64(0.0), + np.int32(1), + np.int32(2), + np.float64(0.0), + diagonal, + offdiag, + np.int32(0), + np.int32(0), + prik_w, + prik_iblock, + prik_isplit, + np.empty(8), + np.empty(6, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dstebz( + b"A", + b"E", + 2, + 0.0, + 0.0, + 1, + 2, + 0.0, + diagonal, + offdiag, + 0, + 0, + f2py_w, + f2py_iblock, + f2py_isplit, + np.empty(8), + np.empty(6, dtype=np.int32), + 0, + ) + scipy_m, scipy_w, scipy_iblock, scipy_isplit, scipy_info = scipy_lapack.dstebz( + diagonal, offdiag, 0, 0.0, 0.0, 1, 2, 0.0, b"E" + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[7] == scipy_m == 2 + assert_allclose_float64(prik_w[:2], [2.0, 3.0]) + assert_allclose_float64(f2py_w[:2], [2.0, 3.0]) + assert_allclose_float64(scipy_w[:2], [2.0, 3.0]) + np.testing.assert_array_equal(prik_iblock, scipy_iblock) + np.testing.assert_array_equal(f2py_iblock, scipy_iblock) + np.testing.assert_array_equal(prik_isplit, scipy_isplit) + np.testing.assert_array_equal(f2py_isplit, scipy_isplit) + + +def test_dstein_computes_tridiagonal_eigenvectors(prik_lapack, scipy_lapack, f2py_lapack): + matrix, diagonal, offdiag = _diagonal_problem() + m, values, iblock, isplit, split_info = scipy_lapack.dstebz(diagonal, offdiag, 0, 0.0, 0.0, 1, 2, 0.0, b"E") + assert split_info == 0 and m == 2 + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + prik_ifail, f2py_ifail = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dstein( + np.int32(2), + diagonal, + offdiag, + np.int32(2), + values, + iblock, + isplit, + prik_z, + np.int32(2), + np.empty(10), + np.empty(2, dtype=np.int32), + prik_ifail, + np.int32(0), + ) + f2py_result = f2py_lapack.dstein( + 2, + diagonal, + offdiag, + 2, + values, + iblock, + isplit, + f2py_z, + np.empty(10), + np.empty(2, dtype=np.int32), + f2py_ifail, + 0, + ) + scipy_z, scipy_info = scipy_lapack.dstein(diagonal, offdiag, values, iblock, isplit) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_eigensystem(matrix, values, prik_z) + _assert_eigensystem(matrix, values, f2py_z) + _assert_eigensystem(matrix, values, scipy_z) + np.testing.assert_array_equal(prik_ifail, [0, 0]) + np.testing.assert_array_equal(f2py_ifail, [0, 0]) + + +def test_dstemr_computes_robust_tridiagonal_eigenpairs(prik_lapack, scipy_lapack, f2py_lapack): + matrix, diagonal, offdiag = _diagonal_problem() + prik_d, f2py_d = diagonal.copy(), diagonal.copy() + prik_e, f2py_e = np.array([offdiag[0], 0.0]), np.array([offdiag[0], 0.0]) + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + prik_support, f2py_support = np.empty(4, dtype=np.int32), np.empty(4, dtype=np.int32) + + prik_scalars = prik_lapack.dstemr( + "V", + "A", + np.int32(2), + prik_d, + prik_e, + np.float64(0.0), + np.float64(0.0), + np.int32(1), + np.int32(2), + np.int32(0), + prik_w, + prik_z, + np.int32(2), + np.int32(2), + prik_support, + np.bool_(True), + np.empty(128), + np.int32(128), + np.empty(64, dtype=np.int32), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dstemr( + b"V", + b"A", + 2, + f2py_d, + f2py_e, + 0.0, + 0.0, + 1, + 2, + 0, + f2py_w, + f2py_z, + 2, + f2py_support, + 1, + np.empty(128), + 128, + np.empty(64, dtype=np.int32), + 64, + 0, + ) + scipy_m, scipy_w, scipy_z, scipy_info = scipy_lapack.dstemr( + diagonal, np.array([0.0, 0.0]), 0, 0.0, 0.0, 1, 2, compute_v=1, lwork=128, liwork=64 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[5] == scipy_m == 2 + _assert_eigensystem(matrix, prik_w, prik_z) + _assert_eigensystem(matrix, f2py_w, f2py_z) + _assert_eigensystem(matrix, scipy_w, scipy_z) + + +def test_dsterf_computes_tridiagonal_eigenvalues(prik_lapack, scipy_lapack, f2py_lapack): + _matrix, diagonal, offdiag = _diagonal_problem() + prik_d, f2py_d = diagonal.copy(), diagonal.copy() + prik_e, f2py_e = offdiag.copy(), offdiag.copy() + + prik_scalars = prik_lapack.dsterf(np.int32(2), prik_d, prik_e, np.int32(0)) + f2py_result = f2py_lapack.dsterf(2, f2py_d, f2py_e, 0) + scipy_values, scipy_info = scipy_lapack.dsterf(diagonal, offdiag) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_d, [2.0, 3.0]) + assert_allclose_float64(f2py_d, [2.0, 3.0]) + assert_allclose_float64(scipy_values, [2.0, 3.0]) + + +def test_dstev_computes_tridiagonal_eigenpairs(prik_lapack, scipy_lapack, f2py_lapack): + matrix, diagonal, offdiag = _diagonal_problem() + prik_d, f2py_d = diagonal.copy(), diagonal.copy() + prik_e, f2py_e = offdiag.copy(), offdiag.copy() + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dstev("V", np.int32(2), prik_d, prik_e, prik_z, np.int32(2), np.empty(4), np.int32(0)) + f2py_result = f2py_lapack.dstev(b"V", 2, f2py_d, f2py_e, f2py_z, np.empty(4), 0) + scipy_values, scipy_z, scipy_info = scipy_lapack.dstev(diagonal, offdiag, compute_v=1) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_eigensystem(matrix, prik_d, prik_z) + _assert_eigensystem(matrix, f2py_d, f2py_z) + _assert_eigensystem(matrix, scipy_values, scipy_z) + + +def test_dstevd_computes_divide_and_conquer_tridiagonal_eigenpairs(prik_lapack, scipy_lapack, f2py_lapack): + matrix, diagonal, offdiag = _diagonal_problem() + prik_d, f2py_d = diagonal.copy(), diagonal.copy() + prik_e, f2py_e = offdiag.copy(), offdiag.copy() + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dstevd( + "V", + np.int32(2), + prik_d, + prik_e, + prik_z, + np.int32(2), + np.empty(64), + np.int32(64), + np.empty(32, dtype=np.int32), + np.int32(32), + np.int32(0), + ) + f2py_result = f2py_lapack.dstevd( + b"V", 2, f2py_d, f2py_e, f2py_z, np.empty(64), 64, np.empty(32, dtype=np.int32), 32, 0 + ) + scipy_values, scipy_z, scipy_info = scipy_lapack.dstevd(diagonal, offdiag, compute_v=1, lwork=64, liwork=32) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_eigensystem(matrix, prik_d, prik_z) + _assert_eigensystem(matrix, f2py_d, f2py_z) + _assert_eigensystem(matrix, scipy_values, scipy_z) + + +def test_dsyev_returns_orthonormal_eigenvectors(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[2.0, 1.0], [1.0, 2.0]], dtype=np.float64) + expected_w = np.array([1.0, 3.0], dtype=np.float64) + prik_vectors, f2py_vectors = column_major(matrix), column_major(matrix) + prik_w = np.empty(2, dtype=np.float64) + f2py_w = np.empty(2, dtype=np.float64) + + prik_scalars = prik_lapack.dsyev( + "V", "U", np.int32(2), prik_vectors, np.int32(2), prik_w, np.empty(16), np.int32(16), np.int32(0) + ) + f2py_result = f2py_lapack.dsyev(b"V", b"U", 2, f2py_vectors, f2py_w, np.empty(16), 16, 0) + scipy_w, scipy_vectors, scipy_info = scipy_lapack.dsyev(matrix.copy(order="F"), compute_v=1, lower=0, lwork=16) + + assert prik_scalars == (2, 2, 16, 0) + assert f2py_result is None + assert scipy_info == 0 + for values, vectors in ( + (prik_w, prik_vectors), + (f2py_w, f2py_vectors), + (scipy_w, scipy_vectors), + ): + assert_allclose_float64(values, expected_w, operation_size=2) + assert_orthogonal(vectors) + assert_allclose_float64(matrix @ vectors, vectors @ np.diag(values), operation_size=2) + + +def test_dsyevd_computes_divide_and_conquer_symmetric_eigenpairs(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _diagonal, _offdiag = _diagonal_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dsyevd( + "V", + "U", + np.int32(2), + prik_a, + np.int32(2), + prik_w, + np.empty(64), + np.int32(64), + np.empty(32, dtype=np.int32), + np.int32(32), + np.int32(0), + ) + f2py_result = f2py_lapack.dsyevd( + b"V", b"U", 2, f2py_a, f2py_w, np.empty(64), 64, np.empty(32, dtype=np.int32), 32, 0 + ) + scipy_w, scipy_a, scipy_info = scipy_lapack.dsyevd( + matrix.copy(order="F"), compute_v=1, lower=0, lwork=64, liwork=32 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + _assert_eigensystem(matrix, prik_w, prik_a) + _assert_eigensystem(matrix, f2py_w, f2py_a) + _assert_eigensystem(matrix, scipy_w, scipy_a) + + +def test_dsyevr_selects_symmetric_eigenpairs_by_index(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _diagonal, _offdiag = _diagonal_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + prik_support, f2py_support = np.empty(4, dtype=np.int32), np.empty(4, dtype=np.int32) + + prik_scalars = prik_lapack.dsyevr( + "V", + "I", + "U", + np.int32(2), + prik_a, + np.int32(2), + np.float64(0.0), + np.float64(0.0), + np.int32(1), + np.int32(2), + np.float64(0.0), + np.int32(0), + prik_w, + prik_z, + np.int32(2), + prik_support, + np.empty(128), + np.int32(128), + np.empty(64, dtype=np.int32), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dsyevr( + b"V", + b"I", + b"U", + 2, + f2py_a, + 0.0, + 0.0, + 1, + 2, + 0.0, + 0, + f2py_w, + f2py_z, + f2py_support, + np.empty(128), + 128, + np.empty(64, dtype=np.int32), + 64, + 0, + ) + scipy_w, scipy_z, scipy_m, _support, scipy_info = scipy_lapack.dsyevr( + matrix.copy(order="F"), compute_v=1, range=b"I", lower=0, il=1, iu=2, lwork=128, liwork=64 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[8] == scipy_m == 2 + _assert_eigensystem(matrix, prik_w, prik_z) + _assert_eigensystem(matrix, f2py_w, f2py_z) + _assert_eigensystem(matrix, scipy_w, scipy_z) + + +def test_dsyevx_selects_symmetric_eigenpairs_by_value(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _diagonal, _offdiag = _diagonal_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_w, f2py_w = np.empty(2), np.empty(2) + prik_z, f2py_z = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + prik_ifail, f2py_ifail = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dsyevx( + "V", + "V", + "U", + np.int32(2), + prik_a, + np.int32(2), + np.float64(1.5), + np.float64(3.5), + np.int32(1), + np.int32(2), + np.float64(0.0), + np.int32(0), + prik_w, + prik_z, + np.int32(2), + np.empty(64), + np.int32(64), + np.empty(10, dtype=np.int32), + prik_ifail, + np.int32(0), + ) + f2py_result = f2py_lapack.dsyevx( + b"V", + b"V", + b"U", + 2, + f2py_a, + 1.5, + 3.5, + 1, + 2, + 0.0, + 0, + f2py_w, + f2py_z, + np.empty(64), + 64, + np.empty(10, dtype=np.int32), + f2py_ifail, + 0, + ) + scipy_w, scipy_z, scipy_m, scipy_ifail, scipy_info = scipy_lapack.dsyevx( + matrix.copy(order="F"), compute_v=1, range=b"V", lower=0, vl=1.5, vu=3.5, lwork=64 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[8] == scipy_m == 2 + _assert_eigensystem(matrix, prik_w, prik_z) + _assert_eigensystem(matrix, f2py_w, f2py_z) + _assert_eigensystem(matrix, scipy_w, scipy_z) + np.testing.assert_array_equal(prik_ifail, scipy_ifail) + np.testing.assert_array_equal(f2py_ifail, scipy_ifail) + + +def test_dsytrd_reduces_symmetric_matrix_to_tridiagonal(prik_lapack, scipy_lapack, f2py_lapack): + matrix, diagonal, offdiag = _diagonal_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_d, f2py_d = np.empty(2), np.empty(2) + prik_e, f2py_e = np.empty(1), np.empty(1) + prik_tau, f2py_tau = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dsytrd( + "U", np.int32(2), prik_a, np.int32(2), prik_d, prik_e, prik_tau, np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dsytrd(b"U", 2, f2py_a, f2py_d, f2py_e, f2py_tau, np.empty(64), 64, 0) + scipy_a, scipy_d, scipy_e, scipy_tau, scipy_info = scipy_lapack.dsytrd(matrix.copy(order="F"), lower=0, lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_d, diagonal) + assert_allclose_float64(f2py_d, diagonal) + assert_allclose_float64(scipy_d, diagonal) + assert_allclose_float64(prik_e, offdiag) + assert_allclose_float64(f2py_e, offdiag) + assert_allclose_float64(scipy_e, offdiag) + assert_allclose_float64(prik_a, scipy_a) + assert_allclose_float64(f2py_a, scipy_a) + assert_allclose_float64(prik_tau, scipy_tau) + assert_allclose_float64(f2py_tau, scipy_tau) diff --git a/examples/lapack/tests/test_least_squares.py b/examples/lapack/tests/test_least_squares.py new file mode 100644 index 000000000..f4196ebff --- /dev/null +++ b/examples/lapack/tests/test_least_squares.py @@ -0,0 +1,218 @@ +"""Least-squares and equality-constrained least-squares correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_small_residual + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def _exact_tall_problem(): + matrix = np.array([[1.0, 0.0], [0.0, 1.0], [1.0, 1.0]], dtype=np.float64, order="F") + expected = np.array([[1.0], [2.0]], dtype=np.float64) + rhs = np.array([[1.0], [2.0], [3.0]], dtype=np.float64, order="F") + return matrix, rhs, expected + + +def _assert_least_squares(matrix, rhs, solution): + residual = matrix @ solution - rhs + assert_small_residual( + residual, + matrix_norm=np.linalg.norm(matrix, ord=np.inf), + solution_norm=np.linalg.norm(solution, ord=np.inf), + operation_size=matrix.shape[0], + ) + assert_allclose_float64(matrix.T @ residual, np.zeros((matrix.shape[1], 1)), operation_size=3) + + +def test_dgels_solves_full_rank_least_squares(prik_lapack, scipy_lapack, f2py_lapack): + matrix, rhs, expected = _exact_tall_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dgels( + "N", + np.int32(3), + np.int32(2), + np.int32(1), + prik_a, + np.int32(3), + prik_b, + np.int32(3), + np.empty(64), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dgels(b"N", 3, 2, 1, f2py_a, f2py_b, np.empty(64), 64, 0) + _factor, scipy_b, scipy_info = scipy_lapack.dgels(matrix.copy(order="F"), rhs.copy(order="F"), trans=b"N", lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for solution in (prik_b[:2], f2py_b[:2], scipy_b[:2]): + assert_allclose_float64(solution, expected, operation_size=3) + _assert_least_squares(matrix, rhs, solution) + + +def test_dgelsd_solves_rank_revealing_least_squares(prik_lapack, scipy_lapack, f2py_lapack): + matrix, rhs, expected = _exact_tall_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + prik_s, f2py_s = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dgelsd( + np.int32(3), + np.int32(2), + np.int32(1), + prik_a, + np.int32(3), + prik_b, + np.int32(3), + prik_s, + np.float64(-1.0), + np.int32(0), + np.empty(802), + np.int32(802), + np.empty(128, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgelsd( + 3, 2, 1, f2py_a, f2py_b, f2py_s, -1.0, 0, np.empty(802), 802, np.empty(128, dtype=np.int32), 0 + ) + scipy_x, scipy_s, scipy_rank, scipy_info = scipy_lapack.dgelsd( + matrix.copy(order="F"), rhs.copy(order="F"), 802, 128, cond=-1.0 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[-3] == scipy_rank == 2 + for solution in (prik_b[:2], f2py_b[:2], scipy_x[:2]): + assert_allclose_float64(solution, expected, operation_size=3) + _assert_least_squares(matrix, rhs, solution) + assert_allclose_float64(prik_s, scipy_s, operation_size=3) + assert_allclose_float64(f2py_s, scipy_s, operation_size=3) + + +def test_dgelss_solves_svd_least_squares(prik_lapack, scipy_lapack, f2py_lapack): + matrix, rhs, expected = _exact_tall_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + prik_s, f2py_s = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dgelss( + np.int32(3), + np.int32(2), + np.int32(1), + prik_a, + np.int32(3), + prik_b, + np.int32(3), + prik_s, + np.float64(-1.0), + np.int32(0), + np.empty(128), + np.int32(128), + np.int32(0), + ) + f2py_result = f2py_lapack.dgelss(3, 2, 1, f2py_a, f2py_b, f2py_s, -1.0, 0, np.empty(128), 128, 0) + _v, scipy_x, scipy_s, scipy_rank, _work, scipy_info = scipy_lapack.dgelss( + matrix.copy(order="F"), rhs.copy(order="F"), cond=-1.0, lwork=128 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[-3] == scipy_rank == 2 + for solution in (prik_b[:2], f2py_b[:2], scipy_x[:2]): + assert_allclose_float64(solution, expected, operation_size=3) + _assert_least_squares(matrix, rhs, solution) + assert_allclose_float64(prik_s, scipy_s, operation_size=3) + assert_allclose_float64(f2py_s, scipy_s, operation_size=3) + + +def test_dgelsy_solves_pivoted_rank_revealing_least_squares(prik_lapack, scipy_lapack, f2py_lapack): + matrix, rhs, expected = _exact_tall_problem() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + prik_jpvt, f2py_jpvt = np.zeros(2, dtype=np.int32), np.zeros(2, dtype=np.int32) + + prik_scalars = prik_lapack.dgelsy( + np.int32(3), + np.int32(2), + np.int32(1), + prik_a, + np.int32(3), + prik_b, + np.int32(3), + prik_jpvt, + np.float64(-1.0), + np.int32(0), + np.empty(128), + np.int32(128), + np.int32(0), + ) + f2py_result = f2py_lapack.dgelsy(3, 2, 1, f2py_a, f2py_b, f2py_jpvt, -1.0, 0, np.empty(128), 128, 0) + _v, scipy_x, scipy_jpvt, scipy_rank, scipy_info = scipy_lapack.dgelsy( + matrix.copy(order="F"), rhs.copy(order="F"), np.zeros(2, dtype=np.int32), -1.0, 128 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[-3] == scipy_rank == 2 + for solution in (prik_b[:2], f2py_b[:2], scipy_x[:2]): + assert_allclose_float64(solution, expected, operation_size=3) + _assert_least_squares(matrix, rhs, solution) + # SciPy preserves LAPACK's one-based JPVT convention for DGELSY. + np.testing.assert_array_equal(prik_jpvt, scipy_jpvt) + np.testing.assert_array_equal(f2py_jpvt, scipy_jpvt) + + +def test_dgglse_solves_equality_constrained_least_squares(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.eye(2, dtype=np.float64, order="F") + constraint = np.array([[1.0, 0.0]], dtype=np.float64, order="F") + target = np.array([1.0, 2.0], dtype=np.float64) + constrained_value = np.array([1.0], dtype=np.float64) + expected = np.array([1.0, 2.0], dtype=np.float64) + prik_x, f2py_x = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dgglse( + np.int32(2), + np.int32(2), + np.int32(1), + matrix.copy(order="F"), + np.int32(2), + constraint.copy(order="F"), + np.int32(1), + target.copy(), + constrained_value.copy(), + prik_x, + np.empty(128), + np.int32(128), + np.int32(0), + ) + f2py_result = f2py_lapack.dgglse( + 2, + 2, + 1, + matrix.copy(order="F"), + constraint.copy(order="F"), + target.copy(), + constrained_value.copy(), + f2py_x, + np.empty(128), + 128, + 0, + ) + _t, _r, _res, scipy_x, scipy_info = scipy_lapack.dgglse( + matrix.copy(order="F"), constraint.copy(order="F"), target.copy(), constrained_value.copy(), lwork=128 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_x, expected, operation_size=2) + assert_allclose_float64(f2py_x, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + assert_allclose_float64(constraint @ prik_x, constrained_value) + assert_allclose_float64(matrix.T @ (matrix @ prik_x - target), np.zeros(2)) diff --git a/examples/lapack/tests/test_linear_banded_tridiagonal.py b/examples/lapack/tests/test_linear_banded_tridiagonal.py new file mode 100644 index 000000000..ef2b8d6a9 --- /dev/null +++ b/examples/lapack/tests/test_linear_banded_tridiagonal.py @@ -0,0 +1,528 @@ +"""General-banded, positive-banded, and tridiagonal correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import ( + assert_allclose_float64, + general_band_storage, + native_pivots, + symmetric_band_storage, +) + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def _general_tridiagonal(): + lower = np.array([1.0], dtype=np.float64) + diagonal = np.array([4.0, 3.0], dtype=np.float64) + upper = np.array([1.0], dtype=np.float64) + rhs = np.array([[6.0], [7.0]], dtype=np.float64, order="F") + expected = np.array([[1.0], [2.0]], dtype=np.float64) + return lower, diagonal, upper, rhs, expected + + +def _general_tridiagonal_factorization(): + lower = np.array([1.0, 1.0], dtype=np.float64) + diagonal = np.array([4.0, 3.0, 2.0], dtype=np.float64) + upper = np.array([1.0, 1.0], dtype=np.float64) + rhs = np.array([[6.0], [10.0], [8.0]], dtype=np.float64, order="F") + expected = np.array([[1.0], [2.0], [3.0]], dtype=np.float64) + return lower, diagonal, upper, rhs, expected + + +def test_dgbcon_estimates_general_band_condition(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([[4.0]], dtype=np.float64, order="F") + native_ipiv = np.array([1], dtype=np.int32) + f2py_rcond = np.array(0.0, dtype=np.float64) + f2py_info = np.array(0, dtype=np.int32) + + prik_scalars = prik_lapack.dgbcon( + "1", + np.int32(1), + np.int32(0), + np.int32(0), + factor.copy(order="F"), + np.int32(1), + native_ipiv, + np.float64(4.0), + np.float64(0.0), + np.empty(3), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgbcon( + b"1", + 1, + 0, + 0, + factor.copy(order="F"), + native_ipiv, + 4.0, + f2py_rcond, + np.empty(3), + np.empty(1, dtype=np.int32), + f2py_info, + ) + scipy_rcond, scipy_info = scipy_lapack.dgbcon(0, 0, factor.copy(order="F"), np.array([0], dtype=np.int32), 4.0) + + assert f2py_result is None + assert prik_scalars[-1] == f2py_info == scipy_info == 0 + assert_allclose_float64(prik_scalars[-2], 1.0) + assert_allclose_float64(f2py_rcond, 1.0) + assert_allclose_float64(scipy_rcond, 1.0) + + +def test_dgbsv_solves_general_band_system(prik_lapack, scipy_lapack, f2py_lapack): + prik_ab, f2py_ab = np.array([[4.0]], order="F"), np.array([[4.0]], order="F") + prik_b, f2py_b = np.array([[8.0]], order="F"), np.array([[8.0]], order="F") + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + + prik_scalars = prik_lapack.dgbsv( + np.int32(1), + np.int32(0), + np.int32(0), + np.int32(1), + prik_ab, + np.int32(1), + prik_piv, + prik_b, + np.int32(1), + np.int32(0), + ) + f2py_result = f2py_lapack.dgbsv(1, 0, 0, 1, f2py_ab, f2py_piv, f2py_b, 0) + scipy_lu, scipy_piv, scipy_x, scipy_info = scipy_lapack.dgbsv( + 0, 0, np.array([[4.0]], order="F"), np.array([[8.0]], order="F") + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[2.0]]) + assert_allclose_float64(f2py_b, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + assert_allclose_float64(prik_ab, scipy_lu) + assert_allclose_float64(f2py_ab, scipy_lu) + np.testing.assert_array_equal(prik_piv, native_pivots(scipy_piv)) + + +def test_dgbtrf_factorizes_general_band_matrix(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0, 1.0], [1.0, 3.0]], dtype=np.float64) + band = general_band_storage(matrix, 1, 1, factor=True) + prik_ab, f2py_ab = band.copy(order="F"), band.copy(order="F") + prik_piv, f2py_piv = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dgbtrf( + np.int32(2), np.int32(2), np.int32(1), np.int32(1), prik_ab, np.int32(4), prik_piv, np.int32(0) + ) + f2py_result = f2py_lapack.dgbtrf(2, 2, 1, 1, f2py_ab, f2py_piv, 0) + scipy_lu, scipy_piv, scipy_info = scipy_lapack.dgbtrf(band.copy(order="F"), 1, 1) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ab, scipy_lu, operation_size=2) + assert_allclose_float64(f2py_ab, scipy_lu, operation_size=2) + np.testing.assert_array_equal(prik_piv, native_pivots(scipy_piv)) + np.testing.assert_array_equal(f2py_piv, native_pivots(scipy_piv)) + + +def test_dgbtrs_solves_from_general_band_lu(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0, 1.0], [1.0, 3.0]], dtype=np.float64) + band = general_band_storage(matrix, 1, 1, factor=True) + scipy_lu, scipy_piv, factor_info = scipy_lapack.dgbtrf(band.copy(order="F"), 1, 1) + assert factor_info == 0 + native_ipiv = native_pivots(scipy_piv) + rhs = np.array([[6.0], [7.0]], dtype=np.float64, order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dgbtrs( + "N", + np.int32(2), + np.int32(1), + np.int32(1), + np.int32(1), + scipy_lu.copy(order="F"), + np.int32(4), + native_ipiv, + prik_b, + np.int32(2), + np.int32(0), + ) + f2py_result = f2py_lapack.dgbtrs(b"N", 2, 1, 1, 1, scipy_lu.copy(order="F"), native_ipiv, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dgbtrs(scipy_lu, 1, 1, rhs.copy(order="F"), scipy_piv) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[1.0], [2.0]], operation_size=2) + assert_allclose_float64(f2py_b, [[1.0], [2.0]], operation_size=2) + assert_allclose_float64(scipy_x, [[1.0], [2.0]], operation_size=2) + + +def test_dgtcon_estimates_tridiagonal_condition(prik_lapack, scipy_lapack, f2py_lapack): + lower, diagonal, upper, _rhs, _expected = _general_tridiagonal_factorization() + scipy_dl, scipy_d, scipy_du, scipy_du2, scipy_piv, factor_info = scipy_lapack.dgttrf(lower, diagonal, upper) + assert factor_info == 0 + native_ipiv = native_pivots(scipy_piv) + anorm = 5.0 + f2py_rcond = np.array(0.0, dtype=np.float64) + f2py_info = np.array(0, dtype=np.int32) + + prik_scalars = prik_lapack.dgtcon( + "1", + np.int32(3), + scipy_dl, + scipy_d, + scipy_du, + scipy_du2, + native_ipiv, + np.float64(anorm), + np.float64(0.0), + np.empty(6), + np.empty(3, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgtcon( + b"1", + 3, + scipy_dl, + scipy_d, + scipy_du, + scipy_du2, + native_ipiv, + anorm, + f2py_rcond, + np.empty(6), + np.empty(3, dtype=np.int32), + f2py_info, + ) + scipy_rcond, scipy_info = scipy_lapack.dgtcon(scipy_dl, scipy_d, scipy_du, scipy_du2, scipy_piv, anorm) + + assert f2py_result is None + assert prik_scalars[-1] == f2py_info == scipy_info == 0 + assert_allclose_float64(prik_scalars[-2], scipy_rcond, operation_size=3) + assert_allclose_float64(f2py_rcond, scipy_rcond, operation_size=3) + assert 0.0 < scipy_rcond <= 1.0 + + +def test_dgtsv_solves_general_tridiagonal_system(prik_lapack, scipy_lapack, f2py_lapack): + lower, diagonal, upper, rhs, expected = _general_tridiagonal() + prik_dl, prik_d, prik_du = lower.copy(), diagonal.copy(), upper.copy() + f2py_dl, f2py_d, f2py_du = lower.copy(), diagonal.copy(), upper.copy() + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dgtsv( + np.int32(2), np.int32(1), prik_dl, prik_d, prik_du, prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dgtsv(2, 1, f2py_dl, f2py_d, f2py_du, f2py_b, 0) + _du2, _d, _du, scipy_x, scipy_info = scipy_lapack.dgtsv(lower, diagonal, upper, rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, expected, operation_size=2) + assert_allclose_float64(f2py_b, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + + +def test_dgtsvx_solves_and_bounds_tridiagonal_error(prik_lapack, scipy_lapack, f2py_lapack): + lower, diagonal, upper, rhs, expected = _general_tridiagonal() + prik_dlf, f2py_dlf = np.empty(1), np.empty(1) + prik_df, f2py_df = np.empty(2), np.empty(2) + prik_duf, f2py_duf = np.empty(1), np.empty(1) + prik_du2, f2py_du2 = np.empty(0), np.empty(0) + prik_piv, f2py_piv = np.empty(2, dtype=np.int32), np.empty(2, dtype=np.int32) + prik_x, f2py_x = np.empty_like(rhs), np.empty_like(rhs) + prik_ferr, f2py_ferr = np.empty(1), np.empty(1) + prik_berr, f2py_berr = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dgtsvx( + "N", + "N", + np.int32(2), + np.int32(1), + lower, + diagonal, + upper, + prik_dlf, + prik_df, + prik_duf, + prik_du2, + prik_piv, + rhs.copy(order="F"), + np.int32(2), + prik_x, + np.int32(2), + np.float64(0.0), + prik_ferr, + prik_berr, + np.empty(6), + np.empty(2, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgtsvx( + b"N", + b"N", + 2, + 1, + lower, + diagonal, + upper, + f2py_dlf, + f2py_df, + f2py_duf, + f2py_du2, + f2py_piv, + rhs.copy(order="F"), + f2py_x, + 0.0, + f2py_ferr, + f2py_berr, + np.empty(6), + np.empty(2, dtype=np.int32), + 0, + ) + _dlf, _df, _duf, _du2, _piv, scipy_x, scipy_rcond, scipy_ferr, scipy_berr, scipy_info = scipy_lapack.dgtsvx( + lower, diagonal, upper, rhs.copy(order="F") + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_x, expected, operation_size=2) + assert_allclose_float64(f2py_x, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + assert_allclose_float64(prik_scalars[-2], scipy_rcond, operation_size=2) + assert_allclose_float64(prik_ferr, scipy_ferr) + assert_allclose_float64(prik_berr, scipy_berr) + + +def test_dgttrf_factorizes_general_tridiagonal_matrix(prik_lapack, scipy_lapack, f2py_lapack): + lower, diagonal, upper, _rhs, _expected = _general_tridiagonal_factorization() + prik_dl, prik_d, prik_du = lower.copy(), diagonal.copy(), upper.copy() + f2py_dl, f2py_d, f2py_du = lower.copy(), diagonal.copy(), upper.copy() + prik_du2, f2py_du2 = np.empty(1), np.empty(1) + prik_piv, f2py_piv = np.empty(3, dtype=np.int32), np.empty(3, dtype=np.int32) + + prik_scalars = prik_lapack.dgttrf(np.int32(3), prik_dl, prik_d, prik_du, prik_du2, prik_piv, np.int32(0)) + f2py_result = f2py_lapack.dgttrf(3, f2py_dl, f2py_d, f2py_du, f2py_du2, f2py_piv, 0) + scipy_dl, scipy_d, scipy_du, _scipy_du2, scipy_piv, scipy_info = scipy_lapack.dgttrf(lower, diagonal, upper) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_dl, scipy_dl) + assert_allclose_float64(prik_d, scipy_d) + assert_allclose_float64(prik_du, scipy_du) + assert_allclose_float64(f2py_dl, scipy_dl) + assert_allclose_float64(f2py_d, scipy_d) + assert_allclose_float64(f2py_du, scipy_du) + # SciPy preserves LAPACK's one-based IPIV convention for DGTTRF. + np.testing.assert_array_equal(prik_piv, scipy_piv) + np.testing.assert_array_equal(f2py_piv, scipy_piv) + + +def test_dgttrs_solves_from_tridiagonal_lu(prik_lapack, scipy_lapack, f2py_lapack): + lower, diagonal, upper, rhs, expected = _general_tridiagonal_factorization() + dl, d, du, du2, scipy_piv, factor_info = scipy_lapack.dgttrf(lower, diagonal, upper) + assert factor_info == 0 + # DGTTRF/DGTTRS preserve native one-based pivots across all three wrappers. + native_ipiv = scipy_piv.copy() + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dgttrs( + "N", np.int32(3), np.int32(1), dl, d, du, du2, native_ipiv, prik_b, np.int32(3), np.int32(0) + ) + f2py_result = f2py_lapack.dgttrs(b"N", 3, 1, dl, d, du, du2, native_ipiv, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dgttrs(dl, d, du, du2, scipy_piv, rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, expected, operation_size=3) + assert_allclose_float64(f2py_b, expected, operation_size=3) + assert_allclose_float64(scipy_x, expected, operation_size=3) + + +def test_dpbsv_solves_positive_definite_band_system(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0, 1.0], [1.0, 3.0]], dtype=np.float64) + band = symmetric_band_storage(matrix, 1, lower=False) + rhs = np.array([[6.0], [7.0]], dtype=np.float64, order="F") + prik_ab, f2py_ab = band.copy(order="F"), band.copy(order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dpbsv( + "U", np.int32(2), np.int32(1), np.int32(1), prik_ab, np.int32(2), prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dpbsv(b"U", 2, 1, 1, f2py_ab, f2py_b, 0) + scipy_factor, scipy_x, scipy_info = scipy_lapack.dpbsv(band.copy(order="F"), rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ab, scipy_factor, operation_size=2) + assert_allclose_float64(f2py_ab, scipy_factor, operation_size=2) + assert_allclose_float64(prik_b, [[1.0], [2.0]], operation_size=2) + assert_allclose_float64(f2py_b, [[1.0], [2.0]], operation_size=2) + assert_allclose_float64(scipy_x, [[1.0], [2.0]], operation_size=2) + + +def test_dpbtrf_factorizes_positive_definite_band_matrix(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0, 1.0], [1.0, 3.0]], dtype=np.float64) + band = symmetric_band_storage(matrix, 1, lower=False) + prik_ab, f2py_ab = band.copy(order="F"), band.copy(order="F") + + prik_scalars = prik_lapack.dpbtrf("U", np.int32(2), np.int32(1), prik_ab, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dpbtrf(b"U", 2, 1, f2py_ab, 0) + scipy_factor, scipy_info = scipy_lapack.dpbtrf(band.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ab, scipy_factor, operation_size=2) + assert_allclose_float64(f2py_ab, scipy_factor, operation_size=2) + + +def test_dpbtrs_solves_from_positive_definite_band_factor(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0, 1.0], [1.0, 3.0]], dtype=np.float64) + band = symmetric_band_storage(matrix, 1, lower=False) + factor, factor_info = scipy_lapack.dpbtrf(band.copy(order="F")) + assert factor_info == 0 + rhs = np.array([[6.0], [7.0]], dtype=np.float64, order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dpbtrs( + "U", np.int32(2), np.int32(1), np.int32(1), factor, np.int32(2), prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dpbtrs(b"U", 2, 1, 1, factor, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dpbtrs(factor, rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[1.0], [2.0]], operation_size=2) + assert_allclose_float64(f2py_b, [[1.0], [2.0]], operation_size=2) + assert_allclose_float64(scipy_x, [[1.0], [2.0]], operation_size=2) + + +def test_dptsv_solves_spd_tridiagonal_system(prik_lapack, scipy_lapack, f2py_lapack): + lower, diagonal, upper, rhs, expected = _general_tridiagonal() + assert_allclose_float64(lower, upper) + prik_d, f2py_d = diagonal.copy(), diagonal.copy() + prik_e, f2py_e = upper.copy(), upper.copy() + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dptsv(np.int32(2), np.int32(1), prik_d, prik_e, prik_b, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dptsv(2, 1, f2py_d, f2py_e, f2py_b, 0) + _d, _e, scipy_x, scipy_info = scipy_lapack.dptsv(diagonal, upper, rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, expected, operation_size=2) + assert_allclose_float64(f2py_b, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + + +def test_dptsvx_solves_and_bounds_spd_tridiagonal_error(prik_lapack, scipy_lapack, f2py_lapack): + _lower, diagonal, offdiag, rhs, expected = _general_tridiagonal() + prik_df, f2py_df = np.empty(2), np.empty(2) + prik_ef, f2py_ef = np.empty(1), np.empty(1) + prik_x, f2py_x = np.empty_like(rhs), np.empty_like(rhs) + prik_ferr, f2py_ferr = np.empty(1), np.empty(1) + prik_berr, f2py_berr = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dptsvx( + "N", + np.int32(2), + np.int32(1), + diagonal, + offdiag, + prik_df, + prik_ef, + rhs.copy(order="F"), + np.int32(2), + prik_x, + np.int32(2), + np.float64(0.0), + prik_ferr, + prik_berr, + np.empty(4), + np.int32(0), + ) + f2py_result = f2py_lapack.dptsvx( + b"N", + 2, + 1, + diagonal, + offdiag, + f2py_df, + f2py_ef, + rhs.copy(order="F"), + f2py_x, + 0.0, + f2py_ferr, + f2py_berr, + np.empty(4), + 0, + ) + _df, _ef, scipy_x, scipy_rcond, scipy_ferr, scipy_berr, scipy_info = scipy_lapack.dptsvx( + diagonal, offdiag, rhs.copy(order="F") + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_x, expected, operation_size=2) + assert_allclose_float64(f2py_x, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + assert_allclose_float64(prik_scalars[-2], scipy_rcond, operation_size=2) + assert_allclose_float64(prik_ferr, scipy_ferr) + assert_allclose_float64(prik_berr, scipy_berr) + + +def test_dpttrf_factorizes_spd_tridiagonal_matrix(prik_lapack, scipy_lapack, f2py_lapack): + _lower, diagonal, offdiag, _rhs, _expected = _general_tridiagonal() + prik_d, f2py_d = diagonal.copy(), diagonal.copy() + prik_e, f2py_e = offdiag.copy(), offdiag.copy() + + prik_scalars = prik_lapack.dpttrf(np.int32(2), prik_d, prik_e, np.int32(0)) + f2py_result = f2py_lapack.dpttrf(2, f2py_d, f2py_e, 0) + scipy_d, scipy_e, scipy_info = scipy_lapack.dpttrf(diagonal, offdiag) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_d, scipy_d) + assert_allclose_float64(prik_e, scipy_e) + assert_allclose_float64(f2py_d, scipy_d) + assert_allclose_float64(f2py_e, scipy_e) + + +def test_dpttrs_solves_from_spd_tridiagonal_factor(prik_lapack, scipy_lapack, f2py_lapack): + _lower, diagonal, offdiag, rhs, expected = _general_tridiagonal() + factor_d, factor_e, factor_info = scipy_lapack.dpttrf(diagonal, offdiag) + assert factor_info == 0 + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dpttrs(np.int32(2), np.int32(1), factor_d, factor_e, prik_b, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dpttrs(2, 1, factor_d, factor_e, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dpttrs(factor_d, factor_e, rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, expected, operation_size=2) + assert_allclose_float64(f2py_b, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + + +def test_dtbtrs_solves_triangular_band_system(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[2.0, 1.0], [0.0, 3.0]], dtype=np.float64) + band = symmetric_band_storage(matrix, 1, lower=False) + rhs = np.array([[4.0], [6.0]], dtype=np.float64, order="F") + expected = np.array([[1.0], [2.0]], dtype=np.float64) + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dtbtrs( + "U", "N", "N", np.int32(2), np.int32(1), np.int32(1), band, np.int32(2), prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dtbtrs(b"U", b"N", b"N", 2, 1, 1, band, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dtbtrs(band, rhs.copy(order="F"), uplo=b"U", trans=b"N", diag=b"N") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, expected, operation_size=2) + assert_allclose_float64(f2py_b, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + assert_allclose_float64(matrix @ prik_b, rhs, operation_size=2) diff --git a/examples/lapack/tests/test_linear_general.py b/examples/lapack/tests/test_linear_general.py new file mode 100644 index 000000000..097cd7d60 --- /dev/null +++ b/examples/lapack/tests/test_linear_general.py @@ -0,0 +1,323 @@ +"""General dense linear-equation correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import ( + active, + assert_allclose_float64, + assert_small_residual, + assert_storage_unchanged, + column_major, + native_pivots, + pivot_matrix, + unpack_lu, +) + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dgecon_estimates_reciprocal_condition(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([[4.0]], dtype=np.float64, order="F") + expected = 1.0 + f2py_rcond = np.array(0.0, dtype=np.float64) + f2py_info = np.array(0, dtype=np.int32) + + prik_scalars = prik_lapack.dgecon( + "1", + np.int32(1), + factor.copy(order="F"), + np.int32(1), + np.float64(4.0), + np.float64(0.0), + np.empty(4), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgecon( + b"1", 1, factor.copy(order="F"), 4.0, f2py_rcond, np.empty(4), np.empty(1, dtype=np.int32), f2py_info + ) + scipy_rcond, scipy_info = scipy_lapack.dgecon(factor.copy(order="F"), 4.0, norm=b"1") + + assert f2py_result is None + assert prik_scalars[-1] == f2py_info == scipy_info == 0 + assert_allclose_float64(prik_scalars[-2], expected) + assert_allclose_float64(f2py_rcond, expected) + assert_allclose_float64(scipy_rcond, expected) + + +def test_dgeequ_computes_row_and_column_scaling(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + prik_r, prik_c = np.empty(1), np.empty(1) + f2py_r, f2py_c = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dgeequ( + np.int32(1), + np.int32(1), + matrix.copy(order="F"), + np.int32(1), + prik_r, + prik_c, + np.float64(0.0), + np.float64(0.0), + np.float64(0.0), + np.int32(0), + ) + f2py_result = f2py_lapack.dgeequ(1, 1, matrix.copy(order="F"), f2py_r, f2py_c, 0.0, 0.0, 0.0, 0) + scipy_r, scipy_c, scipy_rowcnd, scipy_colcnd, scipy_amax, scipy_info = scipy_lapack.dgeequ(matrix) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_r, [0.25]) + assert_allclose_float64(f2py_r, [0.25]) + assert_allclose_float64(prik_c, [1.0]) + assert_allclose_float64(f2py_c, [1.0]) + assert_allclose_float64(prik_scalars[3:6], [scipy_rowcnd, scipy_colcnd, scipy_amax]) + assert_allclose_float64(scipy_r, [0.25]) + assert_allclose_float64(scipy_c, [1.0]) + + +def test_dgeequb_computes_radix_scaling(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + prik_r, prik_c = np.empty(1), np.empty(1) + f2py_r, f2py_c = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dgeequb( + np.int32(1), + np.int32(1), + matrix.copy(order="F"), + np.int32(1), + prik_r, + prik_c, + np.float64(0.0), + np.float64(0.0), + np.float64(0.0), + np.int32(0), + ) + f2py_result = f2py_lapack.dgeequb(1, 1, matrix.copy(order="F"), f2py_r, f2py_c, 0.0, 0.0, 0.0, 0) + scipy_r, scipy_c, scipy_rowcnd, scipy_colcnd, scipy_amax, scipy_info = scipy_lapack.dgeequb(matrix) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_r, scipy_r) + assert_allclose_float64(f2py_r, scipy_r) + assert_allclose_float64(prik_c, scipy_c) + assert_allclose_float64(f2py_c, scipy_c) + assert_allclose_float64(prik_scalars[3:6], [scipy_rowcnd, scipy_colcnd, scipy_amax]) + assert_allclose_float64(prik_r * matrix * prik_c, [[1.0]]) + + +def test_dgesc2_solves_complete_pivot_lu_system(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([[4.0]], dtype=np.float64, order="F") + native_ipiv = np.array([1], dtype=np.int32) + prik_rhs, f2py_rhs = np.array([8.0]), np.array([8.0]) + + prik_scalars = prik_lapack.dgesc2( + np.int32(1), factor.copy(order="F"), np.int32(1), prik_rhs, native_ipiv, native_ipiv, np.float64(0.0) + ) + f2py_result = f2py_lapack.dgesc2(1, factor.copy(order="F"), f2py_rhs, native_ipiv, native_ipiv, 0.0) + scipy_x, scipy_scale = scipy_lapack.dgesc2( + factor.copy(order="F"), np.array([8.0]), np.array([0], dtype=np.int32), np.array([0], dtype=np.int32) + ) + + assert f2py_result is None + assert_allclose_float64(prik_rhs, [2.0]) + assert_allclose_float64(f2py_rhs, [2.0]) + assert_allclose_float64(scipy_x, [2.0]) + assert_allclose_float64(prik_scalars[-1], scipy_scale) + + +def test_dgesvx_solves_and_reports_error_bounds(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + rhs = np.array([[8.0]], dtype=np.float64, order="F") + prik_af, f2py_af = np.empty_like(matrix), np.empty_like(matrix) + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + prik_x, f2py_x = np.empty_like(rhs), np.empty_like(rhs) + prik_ferr, f2py_ferr = np.empty(1), np.empty(1) + prik_berr, f2py_berr = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dgesvx( + "N", + "N", + np.int32(1), + np.int32(1), + matrix.copy(order="F"), + np.int32(1), + prik_af, + np.int32(1), + prik_piv, + "N", + np.ones(1), + np.ones(1), + rhs.copy(order="F"), + np.int32(1), + prik_x, + np.int32(1), + np.float64(0.0), + prik_ferr, + prik_berr, + np.empty(4), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgesvx( + b"N", + b"N", + 1, + 1, + matrix.copy(order="F"), + f2py_af, + f2py_piv, + b"N", + np.ones(1), + np.ones(1), + rhs.copy(order="F"), + f2py_x, + 0.0, + f2py_ferr, + f2py_berr, + np.empty(4), + np.empty(1, dtype=np.int32), + 0, + ) + _a, scipy_lu, scipy_piv, _equed, _r, _c, _b, scipy_x, scipy_rcond, scipy_ferr, scipy_berr, scipy_info = ( + scipy_lapack.dgesvx(matrix.copy(order="F"), rhs.copy(order="F"), fact=b"N", trans=b"N") + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_x, [[2.0]]) + assert_allclose_float64(f2py_x, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + assert_allclose_float64(prik_af, scipy_lu) + assert_allclose_float64(f2py_af, scipy_lu) + np.testing.assert_array_equal(prik_piv, native_pivots(scipy_piv)) + np.testing.assert_array_equal(f2py_piv, native_pivots(scipy_piv)) + assert_allclose_float64(prik_scalars[-2], scipy_rcond) + assert_allclose_float64(prik_ferr, scipy_ferr) + assert_allclose_float64(prik_berr, scipy_berr) + + +def test_dgetc2_factorizes_with_complete_pivoting(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_ipiv, prik_jpiv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + f2py_ipiv, f2py_jpiv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + + prik_scalars = prik_lapack.dgetc2(np.int32(1), prik_a, np.int32(1), prik_ipiv, prik_jpiv, np.int32(0)) + f2py_result = f2py_lapack.dgetc2(1, f2py_a, f2py_ipiv, f2py_jpiv, 0) + scipy_lu, scipy_ipiv, scipy_jpiv, scipy_info = scipy_lapack.dgetc2(matrix.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [[4.0]]) + assert_allclose_float64(f2py_a, [[4.0]]) + assert_allclose_float64(scipy_lu, [[4.0]]) + np.testing.assert_array_equal(prik_ipiv, native_pivots(scipy_ipiv)) + np.testing.assert_array_equal(prik_jpiv, native_pivots(scipy_jpiv)) + + +def test_dgetri_inverts_lu_factorization(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([[4.0]], dtype=np.float64, order="F") + native_ipiv = np.array([1], dtype=np.int32) + prik_a, f2py_a = factor.copy(order="F"), factor.copy(order="F") + + prik_scalars = prik_lapack.dgetri( + np.int32(1), prik_a, np.int32(1), native_ipiv, np.empty(8), np.int32(8), np.int32(0) + ) + f2py_result = f2py_lapack.dgetri(1, f2py_a, native_ipiv, np.empty(8), 8, 0) + scipy_inverse, scipy_info = scipy_lapack.dgetri(factor.copy(order="F"), np.array([0], dtype=np.int32), lwork=8) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [[0.25]]) + assert_allclose_float64(f2py_a, [[0.25]]) + assert_allclose_float64(scipy_inverse, [[0.25]]) + assert_allclose_float64(np.array([[4.0]]) @ prik_a, np.eye(1)) + + +def test_dgesv_solves_general_system(prik_lapack, scipy_lapack, f2py_lapack): + original_a = np.array([[3.0, 1.0], [1.0, 2.0]], dtype=np.float64) + original_b = np.array([[5.0], [5.0]], dtype=np.float64) + expected_x = np.array([[1.0], [2.0]], dtype=np.float64) + prik_a, f2py_a = column_major(original_a), column_major(original_a) + prik_b, f2py_b = column_major(original_b), column_major(original_b) + prik_piv = np.empty(2, dtype=np.int32) + f2py_piv = np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dgesv( + np.int32(2), np.int32(1), prik_a, np.int32(2), prik_piv, prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dgesv(2, 1, f2py_a, f2py_piv, f2py_b, 0) + scipy_lu, scipy_piv, scipy_x, scipy_info = scipy_lapack.dgesv( + original_a.copy(order="F"), original_b.copy(order="F") + ) + + assert prik_scalars == (2, 1, 2, 2, 0) + assert f2py_result is None + assert scipy_info == 0 + assert_allclose_float64(active(prik_b, 2, 1), expected_x, operation_size=2) + assert_allclose_float64(active(f2py_b, 2, 1), expected_x, operation_size=2) + assert_allclose_float64(scipy_x, expected_x, operation_size=2) + assert_allclose_float64(prik_a, scipy_lu, operation_size=2) + assert_allclose_float64(f2py_a, scipy_lu, operation_size=2) + np.testing.assert_array_equal(prik_piv, native_pivots(scipy_piv)) + np.testing.assert_array_equal(f2py_piv, native_pivots(scipy_piv)) + assert_small_residual( + original_a @ prik_b - original_b, + matrix_norm=np.linalg.norm(original_a, ord=np.inf), + solution_norm=np.linalg.norm(prik_b, ord=np.inf), + operation_size=2, + ) + + +def test_dgetrf_reconstructs_pivoted_lu(prik_lapack, scipy_lapack, f2py_lapack): + original = np.array([[0.0, 2.0], [3.0, 4.0]], dtype=np.float64) + prik_a, f2py_a = column_major(original), column_major(original) + prik_piv = np.empty(2, dtype=np.int32) + f2py_piv = np.empty(2, dtype=np.int32) + + prik_scalars = prik_lapack.dgetrf(np.int32(2), np.int32(2), prik_a, np.int32(2), prik_piv, np.int32(0)) + f2py_result = f2py_lapack.dgetrf(2, 2, f2py_a, f2py_piv, 0) + scipy_lu, scipy_piv, scipy_info = scipy_lapack.dgetrf(original.copy(order="F")) + + assert prik_scalars == (2, 2, 2, 0) + assert f2py_result is None + assert scipy_info == 0 + expected_native_piv = native_pivots(scipy_piv) + np.testing.assert_array_equal(prik_piv, expected_native_piv) + np.testing.assert_array_equal(f2py_piv, expected_native_piv) + assert_allclose_float64(prik_a, scipy_lu, operation_size=2) + assert_allclose_float64(f2py_a, scipy_lu, operation_size=2) + lower, upper = unpack_lu(prik_a) + permutation = pivot_matrix(prik_piv, 2, one_based=True) + assert_allclose_float64(permutation @ original, lower @ upper, operation_size=2) + + +def test_dgetrs_solves_from_native_lu(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[3.0, 1.0], [1.0, 2.0]], dtype=np.float64) + original_b = np.array([[5.0], [5.0]], dtype=np.float64) + expected_x = np.array([[1.0], [2.0]], dtype=np.float64) + scipy_lu, scipy_piv, factor_info = scipy_lapack.dgetrf(matrix.copy(order="F")) + assert factor_info == 0 + native_ipiv = native_pivots(scipy_piv) + prik_lu, f2py_lu = column_major(scipy_lu), column_major(scipy_lu) + prik_b, f2py_b = column_major(original_b), column_major(original_b) + + prik_scalars = prik_lapack.dgetrs( + "N", np.int32(2), np.int32(1), prik_lu, np.int32(2), native_ipiv.copy(), prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dgetrs(b"N", 2, 1, f2py_lu, native_ipiv.copy(), f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dgetrs(scipy_lu, scipy_piv, original_b.copy(order="F"), trans=0) + + assert prik_scalars == (2, 1, 2, 2, 0) + assert f2py_result is None + assert scipy_info == 0 + assert_allclose_float64(prik_b, expected_x, operation_size=2) + assert_allclose_float64(f2py_b, expected_x, operation_size=2) + assert_allclose_float64(scipy_x, expected_x, operation_size=2) + assert_storage_unchanged(prik_lu, scipy_lu) + assert_storage_unchanged(f2py_lu, scipy_lu) diff --git a/examples/lapack/tests/test_linear_positive_definite.py b/examples/lapack/tests/test_linear_positive_definite.py new file mode 100644 index 000000000..9fadc9cea --- /dev/null +++ b/examples/lapack/tests/test_linear_positive_definite.py @@ -0,0 +1,389 @@ +"""Symmetric positive-definite linear-equation correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_storage_unchanged, column_major + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dlauum_forms_triangular_product(prik_lapack, scipy_lapack, f2py_lapack): + triangular = np.array([[2.0]], dtype=np.float64, order="F") + prik_a, f2py_a = triangular.copy(order="F"), triangular.copy(order="F") + + prik_scalars = prik_lapack.dlauum("U", np.int32(1), prik_a, np.int32(1), np.int32(0)) + f2py_result = f2py_lapack.dlauum(b"U", 1, f2py_a, 0) + scipy_a, scipy_info = scipy_lapack.dlauum(triangular.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [[4.0]]) + assert_allclose_float64(f2py_a, [[4.0]]) + assert_allclose_float64(scipy_a, [[4.0]]) + + +def test_dpftrf_factorizes_rfp_spd_matrix(prik_lapack, scipy_lapack, f2py_lapack): + prik_a, f2py_a = np.array([4.0]), np.array([4.0]) + + prik_scalars = prik_lapack.dpftrf("N", "U", np.int32(1), prik_a, np.int32(0)) + f2py_result = f2py_lapack.dpftrf(b"N", b"U", 1, f2py_a, 0) + scipy_a, scipy_info = scipy_lapack.dpftrf(1, np.array([4.0]), transr=b"N", uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [2.0]) + assert_allclose_float64(f2py_a, [2.0]) + assert_allclose_float64(scipy_a, [2.0]) + + +def test_dpftri_inverts_rfp_cholesky_factor(prik_lapack, scipy_lapack, f2py_lapack): + prik_a, f2py_a = np.array([2.0]), np.array([2.0]) + + prik_scalars = prik_lapack.dpftri("N", "U", np.int32(1), prik_a, np.int32(0)) + f2py_result = f2py_lapack.dpftri(b"N", b"U", 1, f2py_a, 0) + scipy_a, scipy_info = scipy_lapack.dpftri(1, np.array([2.0]), transr=b"N", uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [0.25]) + assert_allclose_float64(f2py_a, [0.25]) + assert_allclose_float64(scipy_a, [0.25]) + + +def test_dpftrs_solves_from_rfp_cholesky_factor(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([2.0]) + prik_b = np.array([[8.0]], dtype=np.float64, order="F") + f2py_b = prik_b.copy(order="F") + + prik_scalars = prik_lapack.dpftrs("N", "U", np.int32(1), np.int32(1), factor, prik_b, np.int32(1), np.int32(0)) + f2py_result = f2py_lapack.dpftrs(b"N", b"U", 1, 1, factor, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dpftrs(1, factor, np.array([[8.0]], order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[2.0]]) + assert_allclose_float64(f2py_b, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + + +def test_dpocon_estimates_spd_reciprocal_condition(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([[2.0]], dtype=np.float64, order="F") + f2py_rcond = np.array(0.0, dtype=np.float64) + f2py_info = np.array(0, dtype=np.int32) + + prik_scalars = prik_lapack.dpocon( + "U", + np.int32(1), + factor.copy(order="F"), + np.int32(1), + np.float64(4.0), + np.float64(0.0), + np.empty(3), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dpocon( + b"U", 1, factor.copy(order="F"), 4.0, f2py_rcond, np.empty(3), np.empty(1, dtype=np.int32), f2py_info + ) + scipy_rcond, scipy_info = scipy_lapack.dpocon(factor.copy(order="F"), 4.0, uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == f2py_info == scipy_info == 0 + assert_allclose_float64(prik_scalars[-2], 1.0) + assert_allclose_float64(f2py_rcond, 1.0) + assert_allclose_float64(scipy_rcond, 1.0) + + +def test_dposv_solves_spd_system(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + rhs = np.array([[8.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dposv( + "U", np.int32(1), np.int32(1), prik_a, np.int32(1), prik_b, np.int32(1), np.int32(0) + ) + f2py_result = f2py_lapack.dposv(b"U", 1, 1, f2py_a, f2py_b, 0) + scipy_factor, scipy_x, scipy_info = scipy_lapack.dposv(matrix.copy(order="F"), rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, scipy_factor) + assert_allclose_float64(f2py_a, scipy_factor) + assert_allclose_float64(prik_b, [[2.0]]) + assert_allclose_float64(f2py_b, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + + +def test_dposvx_solves_and_bounds_spd_error(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + rhs = np.array([[8.0]], dtype=np.float64, order="F") + prik_af, f2py_af = np.empty_like(matrix), np.empty_like(matrix) + prik_x, f2py_x = np.empty_like(rhs), np.empty_like(rhs) + prik_ferr, f2py_ferr = np.empty(1), np.empty(1) + prik_berr, f2py_berr = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dposvx( + "N", + "U", + np.int32(1), + np.int32(1), + matrix.copy(order="F"), + np.int32(1), + prik_af, + np.int32(1), + "N", + np.ones(1), + rhs.copy(order="F"), + np.int32(1), + prik_x, + np.int32(1), + np.float64(0.0), + prik_ferr, + prik_berr, + np.empty(3), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dposvx( + b"N", + b"U", + 1, + 1, + matrix.copy(order="F"), + f2py_af, + b"N", + np.ones(1), + rhs.copy(order="F"), + f2py_x, + 0.0, + f2py_ferr, + f2py_berr, + np.empty(3), + np.empty(1, dtype=np.int32), + 0, + ) + _a, scipy_factor, _equed, _s, _b, scipy_x, scipy_rcond, scipy_ferr, scipy_berr, scipy_info = scipy_lapack.dposvx( + matrix.copy(order="F"), rhs.copy(order="F"), fact=b"N" + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_af, scipy_factor) + assert_allclose_float64(f2py_af, scipy_factor) + assert_allclose_float64(prik_x, [[2.0]]) + assert_allclose_float64(f2py_x, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + assert_allclose_float64(prik_scalars[-2], scipy_rcond) + assert_allclose_float64(prik_ferr, scipy_ferr) + assert_allclose_float64(prik_berr, scipy_berr) + + +def test_dpotrf_reconstructs_spd_matrix(prik_lapack, scipy_lapack, f2py_lapack): + logical = np.array([[4.0, 1.0], [1.0, 3.0]], dtype=np.float64) + stored = np.array([[4.0, np.nan], [1.0, 3.0]], dtype=np.float64, order="F") + prik_a, f2py_a = column_major(stored), column_major(stored) + + prik_scalars = prik_lapack.dpotrf("L", np.int32(2), prik_a, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dpotrf(b"L", 2, f2py_a, 0) + scipy_factor, scipy_info = scipy_lapack.dpotrf(stored.copy(order="F"), lower=1, clean=0) + + assert prik_scalars == (2, 2, 0) + assert f2py_result is None + assert scipy_info == 0 + prik_lower = np.tril(prik_a) + f2py_lower = np.tril(f2py_a) + scipy_lower = np.tril(scipy_factor) + assert_allclose_float64(prik_lower @ prik_lower.T, logical, operation_size=2) + assert_allclose_float64(f2py_lower @ f2py_lower.T, logical, operation_size=2) + assert_allclose_float64(scipy_lower @ scipy_lower.T, logical, operation_size=2) + assert_allclose_float64(prik_lower, scipy_lower, operation_size=2) + assert_allclose_float64(f2py_lower, scipy_lower, operation_size=2) + assert_storage_unchanged(np.triu(prik_a, 1), np.triu(stored, 1)) + assert_storage_unchanged(np.triu(f2py_a, 1), np.triu(stored, 1)) + + +def test_dpotri_inverts_cholesky_factor(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([[2.0]], dtype=np.float64, order="F") + prik_a, f2py_a = factor.copy(order="F"), factor.copy(order="F") + + prik_scalars = prik_lapack.dpotri("U", np.int32(1), prik_a, np.int32(1), np.int32(0)) + f2py_result = f2py_lapack.dpotri(b"U", 1, f2py_a, 0) + scipy_inverse, scipy_info = scipy_lapack.dpotri(factor.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [[0.25]]) + assert_allclose_float64(f2py_a, [[0.25]]) + assert_allclose_float64(scipy_inverse, [[0.25]]) + + +def test_dpotrs_solves_from_cholesky_factor(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([[2.0]], dtype=np.float64, order="F") + rhs = np.array([[8.0]], dtype=np.float64, order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dpotrs( + "U", np.int32(1), np.int32(1), factor.copy(order="F"), np.int32(1), prik_b, np.int32(1), np.int32(0) + ) + f2py_result = f2py_lapack.dpotrs(b"U", 1, 1, factor.copy(order="F"), f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dpotrs(factor.copy(order="F"), rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[2.0]]) + assert_allclose_float64(f2py_b, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + + +def test_dppcon_estimates_packed_spd_condition(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([2.0]) + f2py_rcond = np.array(0.0, dtype=np.float64) + f2py_info = np.array(0, dtype=np.int32) + + prik_scalars = prik_lapack.dppcon( + "U", + np.int32(1), + factor, + np.float64(4.0), + np.float64(0.0), + np.empty(3), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dppcon( + b"U", 1, factor, 4.0, f2py_rcond, np.empty(3), np.empty(1, dtype=np.int32), f2py_info + ) + scipy_rcond, scipy_info = scipy_lapack.dppcon(1, factor, 4.0) + + assert f2py_result is None + assert prik_scalars[-1] == f2py_info == scipy_info == 0 + assert_allclose_float64(prik_scalars[-2], 1.0) + assert_allclose_float64(f2py_rcond, 1.0) + assert_allclose_float64(scipy_rcond, 1.0) + + +def test_dppsv_solves_packed_spd_system(prik_lapack, scipy_lapack, f2py_lapack): + prik_ap, f2py_ap = np.array([4.0]), np.array([4.0]) + prik_b = np.array([[8.0]], dtype=np.float64, order="F") + f2py_b = prik_b.copy(order="F") + + prik_scalars = prik_lapack.dppsv("U", np.int32(1), np.int32(1), prik_ap, prik_b, np.int32(1), np.int32(0)) + f2py_result = f2py_lapack.dppsv(b"U", 1, 1, f2py_ap, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dppsv(1, np.array([4.0]), np.array([[8.0]], order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ap, [2.0]) + assert_allclose_float64(f2py_ap, [2.0]) + assert_allclose_float64(prik_b, [[2.0]]) + assert_allclose_float64(f2py_b, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + + +def test_dpptrf_factorizes_packed_spd_matrix(prik_lapack, scipy_lapack, f2py_lapack): + prik_ap, f2py_ap = np.array([4.0]), np.array([4.0]) + + prik_scalars = prik_lapack.dpptrf("U", np.int32(1), prik_ap, np.int32(0)) + f2py_result = f2py_lapack.dpptrf(b"U", 1, f2py_ap, 0) + scipy_ap, scipy_info = scipy_lapack.dpptrf(1, np.array([4.0])) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ap, [2.0]) + assert_allclose_float64(f2py_ap, [2.0]) + assert_allclose_float64(scipy_ap, [2.0]) + + +def test_dpptri_inverts_packed_cholesky_factor(prik_lapack, scipy_lapack, f2py_lapack): + prik_ap, f2py_ap = np.array([2.0]), np.array([2.0]) + + prik_scalars = prik_lapack.dpptri("U", np.int32(1), prik_ap, np.int32(0)) + f2py_result = f2py_lapack.dpptri(b"U", 1, f2py_ap, 0) + scipy_ap, scipy_info = scipy_lapack.dpptri(1, np.array([2.0])) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ap, [0.25]) + assert_allclose_float64(f2py_ap, [0.25]) + assert_allclose_float64(scipy_ap, [0.25]) + + +def test_dpptrs_solves_from_packed_cholesky_factor(prik_lapack, scipy_lapack, f2py_lapack): + factor = np.array([2.0]) + prik_b = np.array([[8.0]], dtype=np.float64, order="F") + f2py_b = prik_b.copy(order="F") + + prik_scalars = prik_lapack.dpptrs("U", np.int32(1), np.int32(1), factor, prik_b, np.int32(1), np.int32(0)) + f2py_result = f2py_lapack.dpptrs(b"U", 1, 1, factor, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dpptrs(1, factor, np.array([[8.0]], order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[2.0]]) + assert_allclose_float64(f2py_b, [[2.0]]) + assert_allclose_float64(scipy_x, [[2.0]]) + + +def test_dpstf2_reconstructs_pivoted_cholesky(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + + prik_scalars = prik_lapack.dpstf2( + "U", np.int32(1), prik_a, np.int32(1), prik_piv, np.int32(0), np.float64(-1.0), np.empty(2), np.int32(0) + ) + f2py_result = f2py_lapack.dpstf2(b"U", f2py_a, f2py_piv, 0, -1.0, np.empty(2), 0) + scipy_a, _scipy_piv, scipy_rank, scipy_info = scipy_lapack.dpstf2(matrix.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[2] == scipy_rank == 1 + assert_allclose_float64(prik_a.T @ prik_a, matrix) + assert_allclose_float64(f2py_a.T @ f2py_a, matrix) + assert_allclose_float64(scipy_a.T @ scipy_a, matrix) + np.testing.assert_array_equal(prik_piv, [1]) + np.testing.assert_array_equal(f2py_piv, [1]) + + +def test_dpstrf_reconstructs_blocked_pivoted_cholesky(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + + prik_scalars = prik_lapack.dpstrf( + "U", np.int32(1), prik_a, np.int32(1), prik_piv, np.int32(0), np.float64(-1.0), np.empty(2), np.int32(0) + ) + f2py_result = f2py_lapack.dpstrf(b"U", f2py_a, f2py_piv, 0, -1.0, np.empty(2), 0) + scipy_a, _scipy_piv, scipy_rank, scipy_info = scipy_lapack.dpstrf(matrix.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert prik_scalars[2] == scipy_rank == 1 + assert_allclose_float64(prik_a.T @ prik_a, matrix) + assert_allclose_float64(f2py_a.T @ f2py_a, matrix) + assert_allclose_float64(scipy_a.T @ scipy_a, matrix) + np.testing.assert_array_equal(prik_piv, [1]) + np.testing.assert_array_equal(f2py_piv, [1]) + + +def test_dsfrk_updates_spd_matrix_in_rfp_storage(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[2.0, 3.0]], dtype=np.float64, order="F") + prik_c, f2py_c = np.array([1.0]), np.array([1.0]) + expected = np.array([14.0]) + + prik_scalars = prik_lapack.dsfrk( + "N", "U", "N", np.int32(1), np.int32(2), np.float64(1.0), matrix, np.int32(1), np.float64(1.0), prik_c + ) + f2py_result = f2py_lapack.dsfrk(b"N", b"U", b"N", 1, 2, 1.0, matrix, 1.0, f2py_c) + scipy_c = scipy_lapack.dsfrk(1, 2, 1.0, matrix, 1.0, np.array([1.0])) + + assert f2py_result is None + assert prik_scalars == (1, 2, 1.0, 1, 1.0) + assert_allclose_float64(prik_c, expected, operation_size=2) + assert_allclose_float64(f2py_c, expected, operation_size=2) + assert_allclose_float64(scipy_c, expected, operation_size=2) diff --git a/examples/lapack/tests/test_linear_symmetric_indefinite.py b/examples/lapack/tests/test_linear_symmetric_indefinite.py new file mode 100644 index 000000000..e8c730e2b --- /dev/null +++ b/examples/lapack/tests/test_linear_symmetric_indefinite.py @@ -0,0 +1,274 @@ +"""Symmetric-indefinite factorization and solve correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64 + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def _negative_scalar_factor(): + matrix = np.array([[-4.0]], dtype=np.float64, order="F") + return matrix, np.array([1], dtype=np.int32) + + +def test_dsycon_estimates_symmetric_reciprocal_condition(prik_lapack, scipy_lapack, f2py_lapack): + factor, native_ipiv = _negative_scalar_factor() + f2py_rcond = np.array(0.0, dtype=np.float64) + f2py_info = np.array(0, dtype=np.int32) + + prik_scalars = prik_lapack.dsycon( + "U", + np.int32(1), + factor.copy(order="F"), + np.int32(1), + native_ipiv, + np.float64(4.0), + np.float64(0.0), + np.empty(2), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dsycon( + b"U", + 1, + factor.copy(order="F"), + native_ipiv, + 4.0, + f2py_rcond, + np.empty(2), + np.empty(1, dtype=np.int32), + f2py_info, + ) + scipy_rcond, scipy_info = scipy_lapack.dsycon(factor.copy(order="F"), native_ipiv, 4.0) + + assert f2py_result is None + assert prik_scalars[-1] == f2py_info == scipy_info == 0 + assert_allclose_float64(prik_scalars[-2], 1.0) + assert_allclose_float64(f2py_rcond, 1.0) + assert_allclose_float64(scipy_rcond, 1.0) + + +def test_dsyconv_converts_bunch_kaufman_storage(prik_lapack, scipy_lapack, f2py_lapack): + factor, native_ipiv = _negative_scalar_factor() + prik_a, f2py_a = factor.copy(order="F"), factor.copy(order="F") + prik_e, f2py_e = np.full(1, np.nan), np.full(1, np.nan) + + prik_scalars = prik_lapack.dsyconv("U", "C", np.int32(1), prik_a, np.int32(1), native_ipiv, prik_e, np.int32(0)) + f2py_result = f2py_lapack.dsyconv(b"U", b"C", 1, f2py_a, native_ipiv, f2py_e, 0) + scipy_a, scipy_e, scipy_info = scipy_lapack.dsyconv(factor.copy(order="F"), native_ipiv, lower=0, way=0) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, scipy_a) + assert_allclose_float64(f2py_a, scipy_a) + assert_allclose_float64(prik_e, scipy_e) + assert_allclose_float64(f2py_e, scipy_e) + + +def test_dsyequb_scales_symmetric_matrix(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[4.0]], dtype=np.float64, order="F") + prik_s, f2py_s = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dsyequb( + "U", + np.int32(1), + matrix.copy(order="F"), + np.int32(1), + prik_s, + np.float64(0.0), + np.float64(0.0), + np.empty(3), + np.int32(0), + ) + f2py_result = f2py_lapack.dsyequb(b"U", 1, matrix.copy(order="F"), f2py_s, 0.0, 0.0, np.empty(3), 0) + scipy_s, scipy_scond, scipy_amax, scipy_info = scipy_lapack.dsyequb(matrix.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_s, scipy_s) + assert_allclose_float64(f2py_s, scipy_s) + assert_allclose_float64(prik_scalars[-3:-1], [scipy_scond, scipy_amax]) + assert_allclose_float64(prik_s * matrix * prik_s, [[1.0]]) + + +def test_dsysv_solves_symmetric_indefinite_system(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[-4.0]], dtype=np.float64, order="F") + rhs = np.array([[8.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + + prik_scalars = prik_lapack.dsysv( + "U", + np.int32(1), + np.int32(1), + prik_a, + np.int32(1), + prik_piv, + prik_b, + np.int32(1), + np.empty(8), + np.int32(8), + np.int32(0), + ) + f2py_result = f2py_lapack.dsysv(b"U", 1, 1, f2py_a, f2py_piv, f2py_b, np.empty(8), 8, 0) + scipy_factor, _scipy_piv, scipy_x, scipy_info = scipy_lapack.dsysv( + matrix.copy(order="F"), rhs.copy(order="F"), lwork=8 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[-2.0]]) + assert_allclose_float64(f2py_b, [[-2.0]]) + assert_allclose_float64(scipy_x, [[-2.0]]) + assert_allclose_float64(prik_a, scipy_factor) + assert_allclose_float64(f2py_a, scipy_factor) + assert_allclose_float64(matrix @ prik_b, rhs) + + +def test_dsysvx_solves_and_bounds_symmetric_error(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[-4.0]], dtype=np.float64, order="F") + rhs = np.array([[8.0]], dtype=np.float64, order="F") + prik_af, f2py_af = np.empty_like(matrix), np.empty_like(matrix) + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + prik_x, f2py_x = np.empty_like(rhs), np.empty_like(rhs) + prik_ferr, f2py_ferr = np.empty(1), np.empty(1) + prik_berr, f2py_berr = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dsysvx( + "N", + "U", + np.int32(1), + np.int32(1), + matrix.copy(order="F"), + np.int32(1), + prik_af, + np.int32(1), + prik_piv, + rhs.copy(order="F"), + np.int32(1), + prik_x, + np.int32(1), + np.float64(0.0), + prik_ferr, + prik_berr, + np.empty(3), + np.int32(3), + np.empty(1, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dsysvx( + b"N", + b"U", + 1, + 1, + matrix.copy(order="F"), + f2py_af, + f2py_piv, + rhs.copy(order="F"), + f2py_x, + 0.0, + f2py_ferr, + f2py_berr, + np.empty(3), + 3, + np.empty(1, dtype=np.int32), + 0, + ) + _a, scipy_factor, _piv, _b, scipy_x, scipy_rcond, scipy_ferr, scipy_berr, scipy_info = scipy_lapack.dsysvx( + matrix.copy(order="F"), rhs.copy(order="F"), lwork=3 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_x, [[-2.0]]) + assert_allclose_float64(f2py_x, [[-2.0]]) + assert_allclose_float64(scipy_x, [[-2.0]]) + assert_allclose_float64(prik_af, scipy_factor) + assert_allclose_float64(f2py_af, scipy_factor) + assert_allclose_float64(prik_scalars[-3], scipy_rcond) + assert_allclose_float64(prik_ferr, scipy_ferr) + assert_allclose_float64(prik_berr, scipy_berr) + + +def test_dsytf2_factorizes_symmetric_indefinite_matrix(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _native_ipiv = _negative_scalar_factor() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + + prik_scalars = prik_lapack.dsytf2("U", np.int32(1), prik_a, np.int32(1), prik_piv, np.int32(0)) + f2py_result = f2py_lapack.dsytf2(b"U", 1, f2py_a, f2py_piv, 0) + scipy_factor, _scipy_piv, scipy_info = scipy_lapack.dsytf2(matrix.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [[-4.0]]) + assert_allclose_float64(f2py_a, [[-4.0]]) + assert_allclose_float64(scipy_factor, [[-4.0]]) + np.testing.assert_array_equal(prik_piv, [1]) + np.testing.assert_array_equal(f2py_piv, [1]) + + +def test_dsytrf_factorizes_symmetric_indefinite_matrix(prik_lapack, scipy_lapack, f2py_lapack): + matrix, _native_ipiv = _negative_scalar_factor() + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_piv, f2py_piv = np.empty(1, dtype=np.int32), np.empty(1, dtype=np.int32) + + prik_scalars = prik_lapack.dsytrf( + "U", np.int32(1), prik_a, np.int32(1), prik_piv, np.empty(8), np.int32(8), np.int32(0) + ) + f2py_result = f2py_lapack.dsytrf(b"U", 1, f2py_a, f2py_piv, np.empty(8), 8, 0) + scipy_factor, _scipy_piv, scipy_info = scipy_lapack.dsytrf(matrix.copy(order="F"), lwork=8) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, scipy_factor) + assert_allclose_float64(f2py_a, scipy_factor) + np.testing.assert_array_equal(prik_piv, [1]) + np.testing.assert_array_equal(f2py_piv, [1]) + + +def test_dsytri_inverts_symmetric_indefinite_factor(prik_lapack, scipy_lapack, f2py_lapack): + factor, native_ipiv = _negative_scalar_factor() + prik_a, f2py_a = factor.copy(order="F"), factor.copy(order="F") + + prik_scalars = prik_lapack.dsytri("U", np.int32(1), prik_a, np.int32(1), native_ipiv, np.empty(1), np.int32(0)) + f2py_result = f2py_lapack.dsytri(b"U", 1, f2py_a, native_ipiv, np.empty(1), 0) + scipy_inverse, scipy_info = scipy_lapack.dsytri(factor.copy(order="F"), native_ipiv) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_a, [[-0.25]]) + assert_allclose_float64(f2py_a, [[-0.25]]) + assert_allclose_float64(scipy_inverse, [[-0.25]]) + + +def test_dsytrs_solves_from_symmetric_indefinite_factor(prik_lapack, scipy_lapack, f2py_lapack): + factor, native_ipiv = _negative_scalar_factor() + rhs = np.array([[8.0]], dtype=np.float64, order="F") + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dsytrs( + "U", + np.int32(1), + np.int32(1), + factor.copy(order="F"), + np.int32(1), + native_ipiv, + prik_b, + np.int32(1), + np.int32(0), + ) + f2py_result = f2py_lapack.dsytrs(b"U", 1, 1, factor.copy(order="F"), native_ipiv, f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dsytrs(factor.copy(order="F"), native_ipiv, rhs.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, [[-2.0]]) + assert_allclose_float64(f2py_b, [[-2.0]]) + assert_allclose_float64(scipy_x, [[-2.0]]) diff --git a/examples/lapack/tests/test_linear_triangular.py b/examples/lapack/tests/test_linear_triangular.py new file mode 100644 index 000000000..4d19dfe8a --- /dev/null +++ b/examples/lapack/tests/test_linear_triangular.py @@ -0,0 +1,212 @@ +"""Triangular solve, inverse, condition, packed, and RFP correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_storage_unchanged + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def _upper_triangular(): + logical = np.array([[2.0, 1.0], [0.0, 3.0]], dtype=np.float64) + stored = np.array([[2.0, 1.0], [np.nan, 3.0]], dtype=np.float64, order="F") + packed = np.array([2.0, 1.0, 3.0], dtype=np.float64) + return logical, stored, packed + + +def test_dtfsm_solves_with_rfp_triangular_factor(prik_lapack, scipy_lapack, f2py_lapack): + logical, stored, _packed = _upper_triangular() + rfp, convert_info = scipy_lapack.dtrttf(stored.copy(order="F"), transr=b"N", uplo=b"U") + assert convert_info == 0 + rhs = np.array([[4.0], [6.0]], dtype=np.float64, order="F") + expected = np.array([[1.0], [2.0]], dtype=np.float64) + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dtfsm( + "N", "L", "U", "N", "N", np.int32(2), np.int32(1), np.float64(1.0), rfp, prik_b, np.int32(2) + ) + f2py_result = f2py_lapack.dtfsm(b"N", b"L", b"U", b"N", b"N", 2, 1, 1.0, rfp, f2py_b) + scipy_x = scipy_lapack.dtfsm( + 1.0, rfp, rhs.copy(order="F"), transr=b"N", side=b"L", uplo=b"U", trans=b"N", diag=b"N" + ) + + assert f2py_result is None + assert prik_scalars == (2, 1, 1.0, 2) + assert_allclose_float64(prik_b, expected, operation_size=2) + assert_allclose_float64(f2py_b, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + assert_allclose_float64(logical @ prik_b, rhs, operation_size=2) + + +def test_dtfttp_converts_rfp_to_packed(prik_lapack, scipy_lapack, f2py_lapack): + _logical, stored, expected_packed = _upper_triangular() + rfp, convert_info = scipy_lapack.dtrttf(stored.copy(order="F"), transr=b"N", uplo=b"U") + assert convert_info == 0 + prik_ap, f2py_ap = np.empty(3), np.empty(3) + + prik_scalars = prik_lapack.dtfttp("N", "U", np.int32(2), rfp, prik_ap, np.int32(0)) + f2py_result = f2py_lapack.dtfttp(b"N", b"U", 2, rfp, f2py_ap, 0) + scipy_ap, scipy_info = scipy_lapack.dtfttp(2, rfp, transr=b"N", uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ap, expected_packed) + assert_allclose_float64(f2py_ap, expected_packed) + assert_allclose_float64(scipy_ap, expected_packed) + + +def test_dtfttr_converts_rfp_to_full_triangular(prik_lapack, scipy_lapack, f2py_lapack): + logical, stored, _packed = _upper_triangular() + rfp, convert_info = scipy_lapack.dtrttf(stored.copy(order="F"), transr=b"N", uplo=b"U") + assert convert_info == 0 + prik_a = np.full((2, 2), np.nan, dtype=np.float64, order="F") + f2py_a = prik_a.copy(order="F") + + prik_scalars = prik_lapack.dtfttr("N", "U", np.int32(2), rfp, prik_a, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dtfttr(b"N", b"U", 2, rfp, f2py_a, 0) + scipy_a, scipy_info = scipy_lapack.dtfttr(2, rfp, transr=b"N", uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(np.triu(prik_a), logical) + assert_allclose_float64(np.triu(f2py_a), logical) + assert_allclose_float64(np.triu(scipy_a), logical) + assert_storage_unchanged(np.tril(prik_a, -1), np.tril(stored, -1)) + assert_storage_unchanged(np.tril(f2py_a, -1), np.tril(stored, -1)) + + +def test_dtpttf_converts_packed_to_rfp(prik_lapack, scipy_lapack, f2py_lapack): + _logical, _stored, packed = _upper_triangular() + prik_rfp, f2py_rfp = np.empty(3), np.empty(3) + + prik_scalars = prik_lapack.dtpttf("N", "U", np.int32(2), packed, prik_rfp, np.int32(0)) + f2py_result = f2py_lapack.dtpttf(b"N", b"U", 2, packed, f2py_rfp, 0) + scipy_rfp, scipy_info = scipy_lapack.dtpttf(2, packed, transr=b"N", uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_rfp, scipy_rfp) + assert_allclose_float64(f2py_rfp, scipy_rfp) + + +def test_dtpttr_converts_packed_to_full_triangular(prik_lapack, scipy_lapack, f2py_lapack): + logical, stored, packed = _upper_triangular() + prik_a = np.full((2, 2), np.nan, dtype=np.float64, order="F") + f2py_a = prik_a.copy(order="F") + + prik_scalars = prik_lapack.dtpttr("U", np.int32(2), packed, prik_a, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dtpttr(b"U", 2, packed, f2py_a, 0) + scipy_a, scipy_info = scipy_lapack.dtpttr(2, packed, uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(np.triu(prik_a), logical) + assert_allclose_float64(np.triu(f2py_a), logical) + assert_allclose_float64(np.triu(scipy_a), logical) + assert_storage_unchanged(np.tril(prik_a, -1), np.tril(stored, -1)) + assert_storage_unchanged(np.tril(f2py_a, -1), np.tril(stored, -1)) + + +def test_dtrcon_estimates_triangular_reciprocal_condition(prik_lapack, scipy_lapack, f2py_lapack): + _logical, stored, _packed = _upper_triangular() + f2py_rcond = np.array(0.0, dtype=np.float64) + f2py_info = np.array(0, dtype=np.int32) + + prik_scalars = prik_lapack.dtrcon( + "1", + "U", + "N", + np.int32(2), + stored.copy(order="F"), + np.int32(2), + np.float64(0.0), + np.empty(6), + np.empty(2, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dtrcon( + b"1", + b"U", + b"N", + 2, + stored.copy(order="F"), + f2py_rcond, + np.empty(6), + np.empty(2, dtype=np.int32), + f2py_info, + ) + scipy_rcond, scipy_info = scipy_lapack.dtrcon(stored.copy(order="F"), norm=b"1", uplo=b"U", diag=b"N") + + assert f2py_result is None + assert prik_scalars[-1] == f2py_info == scipy_info == 0 + assert_allclose_float64(prik_scalars[-2], scipy_rcond, operation_size=2) + assert_allclose_float64(f2py_rcond, scipy_rcond, operation_size=2) + assert 0.0 < scipy_rcond <= 1.0 + + +def test_dtrtri_inverts_triangular_matrix(prik_lapack, scipy_lapack, f2py_lapack): + logical, stored, _packed = _upper_triangular() + prik_a, f2py_a = stored.copy(order="F"), stored.copy(order="F") + + prik_scalars = prik_lapack.dtrtri("U", "N", np.int32(2), prik_a, np.int32(2), np.int32(0)) + f2py_result = f2py_lapack.dtrtri(b"U", b"N", 2, f2py_a, 0) + scipy_a, scipy_info = scipy_lapack.dtrtri(stored.copy(order="F"), lower=0, unitdiag=0) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(logical @ np.triu(prik_a), np.eye(2), operation_size=2) + assert_allclose_float64(logical @ np.triu(f2py_a), np.eye(2), operation_size=2) + assert_allclose_float64(logical @ np.triu(scipy_a), np.eye(2), operation_size=2) + + +def test_dtrtrs_solves_triangular_system(prik_lapack, scipy_lapack, f2py_lapack): + logical, stored, _packed = _upper_triangular() + rhs = np.array([[4.0], [6.0]], dtype=np.float64, order="F") + expected = np.array([[1.0], [2.0]], dtype=np.float64) + prik_b, f2py_b = rhs.copy(order="F"), rhs.copy(order="F") + + prik_scalars = prik_lapack.dtrtrs( + "U", "N", "N", np.int32(2), np.int32(1), stored.copy(order="F"), np.int32(2), prik_b, np.int32(2), np.int32(0) + ) + f2py_result = f2py_lapack.dtrtrs(b"U", b"N", b"N", 2, 1, stored.copy(order="F"), f2py_b, 0) + scipy_x, scipy_info = scipy_lapack.dtrtrs(stored.copy(order="F"), rhs.copy(order="F"), lower=0, trans=0, unitdiag=0) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_b, expected, operation_size=2) + assert_allclose_float64(f2py_b, expected, operation_size=2) + assert_allclose_float64(scipy_x, expected, operation_size=2) + assert_allclose_float64(logical @ prik_b, rhs, operation_size=2) + + +def test_dtrttf_converts_full_triangular_to_rfp(prik_lapack, scipy_lapack, f2py_lapack): + _logical, stored, _packed = _upper_triangular() + prik_rfp, f2py_rfp = np.empty(3), np.empty(3) + + prik_scalars = prik_lapack.dtrttf("N", "U", np.int32(2), stored.copy(order="F"), np.int32(2), prik_rfp, np.int32(0)) + f2py_result = f2py_lapack.dtrttf(b"N", b"U", 2, stored.copy(order="F"), f2py_rfp, 0) + scipy_rfp, scipy_info = scipy_lapack.dtrttf(stored.copy(order="F"), transr=b"N", uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_rfp, scipy_rfp) + assert_allclose_float64(f2py_rfp, scipy_rfp) + + +def test_dtrttp_converts_full_triangular_to_packed(prik_lapack, scipy_lapack, f2py_lapack): + _logical, stored, expected_packed = _upper_triangular() + prik_ap, f2py_ap = np.empty(3), np.empty(3) + + prik_scalars = prik_lapack.dtrttp("U", np.int32(2), stored.copy(order="F"), np.int32(2), prik_ap, np.int32(0)) + f2py_result = f2py_lapack.dtrttp(b"U", 2, stored.copy(order="F"), f2py_ap, 0) + scipy_ap, scipy_info = scipy_lapack.dtrttp(stored.copy(order="F"), uplo=b"U") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_ap, expected_packed) + assert_allclose_float64(f2py_ap, expected_packed) + assert_allclose_float64(scipy_ap, expected_packed) diff --git a/examples/lapack/tests/test_orthogonal_factorizations.py b/examples/lapack/tests/test_orthogonal_factorizations.py new file mode 100644 index 000000000..9b31f85db --- /dev/null +++ b/examples/lapack/tests/test_orthogonal_factorizations.py @@ -0,0 +1,370 @@ +"""Orthogonal-factorization and transformation correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_orthogonal, column_major, qr_q_from_reflectors + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dgemqrt_applies_compact_wy_reflector(prik_lapack, scipy_lapack, f2py_lapack): + original = np.array([[3.0], [4.0]], dtype=np.float64, order="F") + factor, compact_t, factor_info = scipy_lapack.dgeqrt(1, original.copy(order="F")) + assert factor_info == 0 + vector = np.array([1.0, factor[1, 0]], dtype=np.float64) + q = np.eye(2) - compact_t[0, 0] * np.outer(vector, vector) + target = np.array([[2.0], [1.0]], dtype=np.float64, order="F") + expected = q @ target + prik_c, f2py_c = target.copy(order="F"), target.copy(order="F") + + prik_scalars = prik_lapack.dgemqrt( + "L", + "N", + np.int32(2), + np.int32(1), + np.int32(1), + np.int32(1), + factor, + np.int32(2), + compact_t, + np.int32(1), + prik_c, + np.int32(2), + np.empty(1), + np.int32(0), + ) + f2py_result = f2py_lapack.dgemqrt(b"L", b"N", 2, 1, 1, 1, factor, compact_t, f2py_c, np.empty(1), 0) + scipy_c, scipy_info = scipy_lapack.dgemqrt(factor, compact_t, target.copy(order="F"), side=b"L", trans=b"N") + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_c, expected, operation_size=2) + assert_allclose_float64(f2py_c, expected, operation_size=2) + assert_allclose_float64(scipy_c, expected, operation_size=2) + + +def test_dgeqp3_reconstructs_column_pivoted_qr(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 5.0], [2.0, 6.0], [3.0, 8.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_jpvt, f2py_jpvt = np.zeros(2, dtype=np.int32), np.zeros(2, dtype=np.int32) + prik_tau, f2py_tau = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dgeqp3( + np.int32(3), np.int32(2), prik_a, np.int32(3), prik_jpvt, prik_tau, np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dgeqp3(3, 2, f2py_a, f2py_jpvt, f2py_tau, np.empty(64), 64, 0) + scipy_qr, scipy_jpvt, _scipy_tau, _work, scipy_info = scipy_lapack.dgeqp3(matrix.copy(order="F"), lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for factor, tau, pivots in ((prik_a, prik_tau, prik_jpvt), (f2py_a, f2py_tau, f2py_jpvt)): + q = qr_q_from_reflectors(factor, tau) + r = np.triu(factor[:2, :]) + assert_allclose_float64(q @ r, matrix[:, pivots - 1], operation_size=3) + assert_allclose_float64(prik_a, scipy_qr, operation_size=3) + assert_allclose_float64(f2py_a, scipy_qr, operation_size=3) + # SciPy preserves LAPACK's one-based JPVT convention for DGEQP3. + np.testing.assert_array_equal(prik_jpvt, scipy_jpvt) + np.testing.assert_array_equal(f2py_jpvt, scipy_jpvt) + + +def test_dgeqrf_reconstructs_qr_factorization(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 7.0]], dtype=np.float64) + prik_a, f2py_a = column_major(matrix), column_major(matrix) + prik_tau = np.empty(2, dtype=np.float64) + f2py_tau = np.empty(2, dtype=np.float64) + + prik_scalars = prik_lapack.dgeqrf( + np.int32(3), np.int32(2), prik_a, np.int32(3), prik_tau, np.empty(16), np.int32(16), np.int32(0) + ) + f2py_result = f2py_lapack.dgeqrf(3, 2, f2py_a, f2py_tau, np.empty(16), 16, 0) + scipy_qr, scipy_tau, _scipy_work, scipy_info = scipy_lapack.dgeqrf(matrix.copy(order="F"), lwork=16) + + assert prik_scalars == (3, 2, 3, 16, 0) + assert f2py_result is None + assert scipy_info == 0 + for factor, tau in ((prik_a, prik_tau), (f2py_a, f2py_tau), (scipy_qr, scipy_tau)): + q = qr_q_from_reflectors(factor, tau) + r = np.triu(factor[:2, :]) + assert_orthogonal(q) + assert_allclose_float64(q @ r, matrix, operation_size=3) + assert_allclose_float64(prik_a, scipy_qr, operation_size=3) + assert_allclose_float64(f2py_a, scipy_qr, operation_size=3) + assert_allclose_float64(prik_tau, scipy_tau, operation_size=3) + assert_allclose_float64(f2py_tau, scipy_tau, operation_size=3) + + +def test_dgeqrfp_reconstructs_qr_with_nonnegative_diagonal(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [3.0, -4.0], [5.0, 7.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_tau, f2py_tau = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dgeqrfp( + np.int32(3), np.int32(2), prik_a, np.int32(3), prik_tau, np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dgeqrfp(3, 2, f2py_a, f2py_tau, np.empty(64), 64, 0) + scipy_qr, scipy_tau, scipy_info = scipy_lapack.dgeqrfp(matrix.copy(order="F"), lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for factor, tau in ((prik_a, prik_tau), (f2py_a, f2py_tau), (scipy_qr, scipy_tau)): + q = qr_q_from_reflectors(factor, tau) + r = np.triu(factor[:2, :]) + assert_allclose_float64(q @ r, matrix, operation_size=3) + assert np.all(np.diag(r) >= 0.0) + + +def test_dgeqrt_reconstructs_compact_wy_qr(prik_lapack, scipy_lapack, f2py_lapack): + original = np.array([[3.0], [4.0]], dtype=np.float64, order="F") + prik_a, f2py_a = original.copy(order="F"), original.copy(order="F") + prik_t, f2py_t = np.empty((1, 1), order="F"), np.empty((1, 1), order="F") + + prik_scalars = prik_lapack.dgeqrt( + np.int32(2), np.int32(1), np.int32(1), prik_a, np.int32(2), prik_t, np.int32(1), np.empty(1), np.int32(0) + ) + f2py_result = f2py_lapack.dgeqrt(2, 1, 1, f2py_a, f2py_t, np.empty(1), 0) + scipy_a, scipy_t, scipy_info = scipy_lapack.dgeqrt(1, original.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for factor, compact_t in ((prik_a, prik_t), (f2py_a, f2py_t), (scipy_a, scipy_t)): + vector = np.array([1.0, factor[1, 0]]) + q = np.eye(2) - compact_t[0, 0] * np.outer(vector, vector) + assert_orthogonal(q) + assert_allclose_float64(q @ np.array([[factor[0, 0]], [0.0]]), original, operation_size=2) + + +def test_dgerqf_reconstructs_rq_factorization(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[3.0, 4.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_tau, f2py_tau = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dgerqf( + np.int32(1), np.int32(2), prik_a, np.int32(1), prik_tau, np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dgerqf(1, 2, f2py_a, f2py_tau, np.empty(64), 64, 0) + scipy_rq, scipy_tau, _work, scipy_info = scipy_lapack.dgerqf(matrix.copy(order="F"), lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for factor, tau in ((prik_a, prik_tau), (f2py_a, f2py_tau), (scipy_rq, scipy_tau)): + vector = np.array([factor[0, 0], 1.0]) + q = np.eye(2) - tau[0] * np.outer(vector, vector) + assert_allclose_float64(np.array([[0.0, factor[0, 1]]]) @ q, matrix, operation_size=2) + + +def test_dorgqr_forms_explicit_orthogonal_q(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 7.0]], dtype=np.float64) + factor, tau, _work, factor_info = scipy_lapack.dgeqrf(matrix.copy(order="F"), lwork=16) + assert factor_info == 0 + r = np.triu(factor[:2, :]) + prik_q, f2py_q = column_major(factor), column_major(factor) + + prik_scalars = prik_lapack.dorgqr( + np.int32(3), np.int32(2), np.int32(2), prik_q, np.int32(3), tau.copy(), np.empty(16), np.int32(16), np.int32(0) + ) + f2py_result = f2py_lapack.dorgqr(3, 2, 2, f2py_q, tau.copy(), np.empty(16), 16, 0) + scipy_q, _scipy_work, scipy_info = scipy_lapack.dorgqr(factor.copy(order="F"), tau.copy(), lwork=16) + + assert prik_scalars == (3, 2, 2, 3, 16, 0) + assert f2py_result is None + assert scipy_info == 0 + for q in (prik_q, f2py_q, scipy_q): + assert_orthogonal(q) + assert_allclose_float64(q @ r, matrix, operation_size=3) + assert_allclose_float64(prik_q, scipy_q, operation_size=3) + assert_allclose_float64(f2py_q, scipy_q, operation_size=3) + + +def test_dorgrq_forms_explicit_row_orthogonal_q(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[3.0, 4.0]], dtype=np.float64, order="F") + factor, tau, _work, factor_info = scipy_lapack.dgerqf(matrix.copy(order="F"), lwork=64) + assert factor_info == 0 + r = factor[0, 1] + prik_q, f2py_q = factor.copy(order="F"), factor.copy(order="F") + + prik_scalars = prik_lapack.dorgrq( + np.int32(1), np.int32(2), np.int32(1), prik_q, np.int32(1), tau.copy(), np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dorgrq(1, 2, 1, f2py_q, tau.copy(), np.empty(64), 64, 0) + scipy_q, _work, scipy_info = scipy_lapack.dorgrq(factor.copy(order="F"), tau.copy(), lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for q in (prik_q, f2py_q, scipy_q): + assert_allclose_float64(q @ q.T, np.eye(1), operation_size=2) + assert_allclose_float64(r * q, matrix, operation_size=2) + + +def test_dormqr_applies_qr_reflectors(prik_lapack, scipy_lapack, f2py_lapack): + source = np.array([[3.0], [4.0]], dtype=np.float64, order="F") + factor, tau, _work, factor_info = scipy_lapack.dgeqrf(source.copy(order="F"), lwork=64) + assert factor_info == 0 + reflector = np.array([1.0, factor[1, 0]], dtype=np.float64) + q = np.eye(2, dtype=np.float64) - tau[0] * np.outer(reflector, reflector) + target = np.array([[2.0], [1.0]], dtype=np.float64, order="F") + expected = q @ target + prik_c, f2py_c = target.copy(order="F"), target.copy(order="F") + + prik_scalars = prik_lapack.dormqr( + "L", + "N", + np.int32(2), + np.int32(1), + np.int32(1), + factor, + np.int32(2), + tau, + prik_c, + np.int32(2), + np.empty(64), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dormqr(b"L", b"N", 2, 1, 1, factor, tau, f2py_c, np.empty(64), 64, 0) + scipy_c, _work, scipy_info = scipy_lapack.dormqr(b"L", b"N", factor, tau, target.copy(order="F"), 64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_c, expected, operation_size=2) + assert_allclose_float64(f2py_c, expected, operation_size=2) + assert_allclose_float64(scipy_c, expected, operation_size=2) + + +def test_dormrz_applies_rz_reflector(prik_lapack, scipy_lapack, f2py_lapack): + source = np.array([[3.0, 4.0]], dtype=np.float64, order="F") + factor, tau, factor_info = scipy_lapack.dtzrzf(source.copy(order="F"), lwork=64) + assert factor_info == 0 + vector = np.array([1.0, factor[0, 1]]) + z = np.eye(2) - tau[0] * np.outer(vector, vector) + target = np.array([[2.0, 1.0]], dtype=np.float64, order="F") + expected = target @ z + prik_c, f2py_c = target.copy(order="F"), target.copy(order="F") + + prik_scalars = prik_lapack.dormrz( + "R", + "N", + np.int32(1), + np.int32(2), + np.int32(1), + np.int32(1), + factor, + np.int32(1), + tau, + prik_c, + np.int32(1), + np.empty(64), + np.int32(64), + np.int32(0), + ) + f2py_result = f2py_lapack.dormrz(b"R", b"N", 1, 2, 1, 1, factor, tau, f2py_c, np.empty(64), 64, 0) + scipy_c, scipy_info = scipy_lapack.dormrz(factor, tau, target.copy(order="F"), side=b"R", trans=b"N", lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(prik_c, expected, operation_size=2) + assert_allclose_float64(f2py_c, expected, operation_size=2) + assert_allclose_float64(scipy_c, expected, operation_size=2) + + +def test_dtpmqrt_applies_triangular_pentagonal_reflector(prik_lapack, scipy_lapack, f2py_lapack): + top = np.array([[2.0]], dtype=np.float64, order="F") + bottom = np.array([[3.0]], dtype=np.float64, order="F") + _factor_a, factor_b, compact_t, factor_info = scipy_lapack.dtpqrt(0, 1, top.copy(order="F"), bottom.copy(order="F")) + assert factor_info == 0 + vector = np.array([1.0, factor_b[0, 0]]) + q = np.eye(2) - compact_t[0, 0] * np.outer(vector, vector) + target_a = np.array([[4.0]], dtype=np.float64, order="F") + target_b = np.array([[5.0]], dtype=np.float64, order="F") + expected = q @ np.vstack((target_a, target_b)) + prik_a, prik_b = target_a.copy(order="F"), target_b.copy(order="F") + f2py_a, f2py_b = target_a.copy(order="F"), target_b.copy(order="F") + + prik_scalars = prik_lapack.dtpmqrt( + "L", + "N", + np.int32(1), + np.int32(1), + np.int32(1), + np.int32(0), + np.int32(1), + factor_b, + np.int32(1), + compact_t, + np.int32(1), + prik_a, + np.int32(1), + prik_b, + np.int32(1), + np.empty(1), + np.int32(0), + ) + f2py_result = f2py_lapack.dtpmqrt(b"L", b"N", 1, 1, 1, 0, 1, factor_b, compact_t, f2py_a, f2py_b, np.empty(1), 0) + scipy_a, scipy_b, scipy_info = scipy_lapack.dtpmqrt( + 0, factor_b, compact_t, target_a.copy(order="F"), target_b.copy(order="F"), side=b"L", trans=b"N" + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + assert_allclose_float64(np.vstack((prik_a, prik_b)), expected, operation_size=2) + assert_allclose_float64(np.vstack((f2py_a, f2py_b)), expected, operation_size=2) + assert_allclose_float64(np.vstack((scipy_a, scipy_b)), expected, operation_size=2) + + +def test_dtpqrt_reconstructs_triangular_pentagonal_qr(prik_lapack, scipy_lapack, f2py_lapack): + top = np.array([[2.0]], dtype=np.float64, order="F") + bottom = np.array([[3.0]], dtype=np.float64, order="F") + prik_a, f2py_a = top.copy(order="F"), top.copy(order="F") + prik_b, f2py_b = bottom.copy(order="F"), bottom.copy(order="F") + prik_t, f2py_t = np.empty((1, 1), order="F"), np.empty((1, 1), order="F") + + prik_scalars = prik_lapack.dtpqrt( + np.int32(1), + np.int32(1), + np.int32(0), + np.int32(1), + prik_a, + np.int32(1), + prik_b, + np.int32(1), + prik_t, + np.int32(1), + np.empty(1), + np.int32(0), + ) + f2py_result = f2py_lapack.dtpqrt(1, 1, 0, 1, f2py_a, f2py_b, f2py_t, np.empty(1), 0) + scipy_a, scipy_b, scipy_t, scipy_info = scipy_lapack.dtpqrt(0, 1, top.copy(order="F"), bottom.copy(order="F")) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for factor_a, factor_b, compact_t in ( + (prik_a, prik_b, prik_t), + (f2py_a, f2py_b, f2py_t), + (scipy_a, scipy_b, scipy_t), + ): + vector = np.array([1.0, factor_b[0, 0]]) + q = np.eye(2) - compact_t[0, 0] * np.outer(vector, vector) + assert_allclose_float64(q @ np.array([[factor_a[0, 0]], [0.0]]), np.vstack((top, bottom)), operation_size=2) + + +def test_dtzrzf_reconstructs_rz_factorization(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[3.0, 4.0]], dtype=np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_tau, f2py_tau = np.empty(1), np.empty(1) + + prik_scalars = prik_lapack.dtzrzf( + np.int32(1), np.int32(2), prik_a, np.int32(1), prik_tau, np.empty(64), np.int32(64), np.int32(0) + ) + f2py_result = f2py_lapack.dtzrzf(1, 2, f2py_a, f2py_tau, np.empty(64), 64, 0) + scipy_a, scipy_tau, scipy_info = scipy_lapack.dtzrzf(matrix.copy(order="F"), lwork=64) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for factor, tau in ((prik_a, prik_tau), (f2py_a, f2py_tau), (scipy_a, scipy_tau)): + vector = np.array([1.0, factor[0, 1]]) + z = np.eye(2) - tau[0] * np.outer(vector, vector) + assert_allclose_float64(np.array([[factor[0, 0], 0.0]]) @ z, matrix, operation_size=2) diff --git a/examples/lapack/tests/test_routine_coverage.py b/examples/lapack/tests/test_routine_coverage.py new file mode 100644 index 000000000..1ee6c578e --- /dev/null +++ b/examples/lapack/tests/test_routine_coverage.py @@ -0,0 +1,237 @@ +"""Fail-closed audit for the reviewed SciPy float64 LAPACK surface.""" + +from __future__ import annotations + +import ast +import re +from pathlib import Path + +import pytest + +from ..routine_inventory import ( + EXPLICIT_TEST_NAMES, + EXPECTED_LAPACK_PROCEDURES, + EXPECTED_LAPACK_SOURCE_FILES, + F2PY_EXPORT_LIMITATIONS, + F2PY_FUNCTION_RESULTS, + F2PY_SCALAR_WRITEBACK_ROUTINES, + PRIK_ABI_ADAPTERS, + ROUTINE_FAMILIES, + ROUTINE_GROUPS, + ROUTINE_SPECS, + ROUTINES, + SCIPY_VERSION, +) + + +TEST_ROOT = Path(__file__).resolve().parent +EXAMPLE_ROOT = TEST_ROOT.parent +NATIVE_ROOT = EXAMPLE_ROOT / "native" +LAPACK_PYF = EXAMPLE_ROOT / "lapack.pyf" +LAPACK_F2CMAP = EXAMPLE_ROOT / "lapack.f2cmap" +FORTRAN_SUFFIXES = {".f", ".f90", ".f95", ".f03", ".f08", ".for", ".f77", ".ftn"} +F2PY_INOUT_ARGUMENTS: dict[str, tuple[str, ...]] = { + "dlarfg": ("alpha", "tau"), + "dlartg": ("c", "s", "r"), + "dgbcon": ("rcond", "info"), + "dgecon": ("rcond", "info"), + "dgtcon": ("rcond", "info"), + "dpocon": ("rcond", "info"), + "dppcon": ("rcond", "info"), + "dsycon": ("rcond", "info"), + "dtrcon": ("rcond", "info"), +} +PYF_PROCEDURE = re.compile( + r"^\s*(subroutine|function)\s+([a-z]\w*)\s*\(.*?^\s*end\s+\1\s+\2\s*$", + re.IGNORECASE | re.MULTILINE | re.DOTALL, +) +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def _pyf_procedures() -> dict[str, str]: + text = LAPACK_PYF.read_text(encoding="utf-8") + return {match.group(2).lower(): match.group(0) for match in PYF_PROCEDURE.finditer(text)} + + +def _inout_arguments(block: str) -> set[str]: + return { + argument.strip().lower() + for line in block.splitlines() + if "intent(inout)" in line.lower() and "::" in line + for argument in line.split("::", 1)[1].split(",") + } + + +def _explicit_test_owners() -> dict[str, list[tuple[str, Path]]]: + owners: dict[str, list[tuple[str, Path]]] = {} + for path in sorted(TEST_ROOT.glob("test_*.py")): + tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) + for node in tree.body: + if not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)): + continue + matches = [routine for routine, test_name in EXPLICIT_TEST_NAMES.items() if node.name == test_name] + assert len(matches) <= 1, f"{node.name} ambiguously owns {matches}" + if matches: + owners.setdefault(matches[0], []).append((node.name, path)) + return owners + + +def _visible_wrapper_calls(path: Path, test_name: str, routine: str) -> set[str]: + tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) + test_node = next( + node + for node in tree.body + if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef)) and node.name == test_name + ) + return { + call.func.value.id + for call in ast.walk(test_node) + if isinstance(call, ast.Call) + and isinstance(call.func, ast.Attribute) + and call.func.attr == routine + and isinstance(call.func.value, ast.Name) + } + + +def test_inventory_is_unique_and_matches_pinned_scipy_surface(scipy_lapack): + """The reviewed inventory exactly matches SciPy's native d* surface.""" + observed = tuple( + sorted( + name + for name in dir(scipy_lapack) + if name.startswith("d") and callable(getattr(scipy_lapack, name)) and not name.endswith("_lwork") + ) + ) + assert len(ROUTINES) == 127 + assert len(set(ROUTINES)) == len(ROUTINES) + assert tuple(sorted(ROUTINES)) == observed, f"inventory drifted from SciPy {SCIPY_VERSION}" + + +def test_inventory_groups_form_one_complete_partition(): + """Every selected routine has exactly one LAPACK family owner.""" + grouped = tuple(name for names in ROUTINE_GROUPS.values() for name in names) + assert grouped == ROUTINES + assert len(set(grouped)) == len(grouped) + assert set(ROUTINE_FAMILIES) == set(ROUTINES) + assert set(ROUTINE_SPECS) == set(ROUTINES) + assert set(F2PY_INOUT_ARGUMENTS) == F2PY_SCALAR_WRITEBACK_ROUTINES + for routine, spec in ROUTINE_SPECS.items(): + assert spec.native_name == routine + assert spec.family == ROUTINE_FAMILIES[routine] + assert spec.test_name == EXPLICIT_TEST_NAMES[routine] + assert all( + ( + spec.source_file, + spec.scipy_name, + spec.prik_export, + spec.prik_adapter, + spec.f2py_export, + spec.f2py_behavior, + spec.mutation, + spec.returns, + spec.workspace, + spec.index_convention, + spec.oracle, + ) + ) + assert set(ROUTINES) >= F2PY_FUNCTION_RESULTS + assert set(F2PY_EXPORT_LIMITATIONS) <= set(ROUTINES) + assert set(PRIK_ABI_ADAPTERS) <= set(ROUTINES) + + +def test_committed_f2py_signature_matches_selected_surface(): + """The reviewed signature exposes exactly the supported comparison surface.""" + procedures = _pyf_procedures() + expected = set(ROUTINES) - set(F2PY_EXPORT_LIMITATIONS) + assert len(procedures) == len(expected) == 125 + assert set(procedures) == expected + assert re.search(r"^\s*module\s+la_constants\s*$", LAPACK_PYF.read_text(encoding="utf-8"), re.MULTILINE) + assert LAPACK_F2CMAP.read_text(encoding="utf-8") == "{'real': {'wp': 'double'}}\n" + + +def test_committed_f2py_signature_records_scalar_writebacks(): + observed = { + routine: arguments for routine, block in _pyf_procedures().items() if (arguments := _inout_arguments(block)) + } + assert observed == {routine: set(arguments) for routine, arguments in F2PY_INOUT_ARGUMENTS.items()} + + +def test_f2py_script_compiles_the_signature_and_reuses_the_native_library(): + script = (EXAMPLE_ROOT / "build_f2py.sh").read_text(encoding="utf-8") + assert 'python -m numpy.f2py -c \\\n "$EXAMPLE_WORKSPACE/examples/lapack/lapack.pyf"' in script + assert '"-L$(dirname "$LAPACK_SHARED_LIBRARY")"' in script + assert "-lprik_full_lapack" in script + assert '--f2cmap "$EXAMPLE_WORKSPACE/examples/lapack/lapack.f2cmap"' in script + assert '--f90flags="-O0 -I$LAPACK_MODULE_DIR"' in script + assert "examples/lapack/native" not in script + + +def test_documented_scripts_place_both_wrappers_under_one_build_root(prik_lapack, f2py_lapack): + prik_root = Path(prik_lapack.__file__).resolve().parent.parent + f2py_root = Path(f2py_lapack.__file__).resolve().parent.parent + assert prik_root == f2py_root + + +def test_authoritative_native_source_boundary_is_complete_and_unique(): + """The maintained source owner contains the complete library corpus once.""" + sources = tuple( + sorted(path for path in NATIVE_ROOT.iterdir() if path.is_file() and path.suffix.lower() in FORTRAN_SUFFIXES) + ) + stems = {path.stem.lower() for path in sources} + assert len(sources) == EXPECTED_LAPACK_SOURCE_FILES + assert EXPECTED_LAPACK_PROCEDURES == EXPECTED_LAPACK_SOURCE_FILES + 4 + assert set(ROUTINES) <= stems + for routine, spec in ROUTINE_SPECS.items(): + assert (NATIVE_ROOT / spec.source_file).is_file(), routine + assert {"la_constants", "la_xisnan"} <= stems + + +def test_selected_routines_have_one_explicit_named_test(): + """Static AST ownership prevents generated or silently missing tests.""" + owners = _explicit_test_owners() + assert set(owners) == set(ROUTINES) + duplicates = {routine: tests for routine, tests in owners.items() if len(tests) != 1} + assert duplicates == {} + + +def test_selected_tests_keep_all_wrapper_calls_visible(): + """Named tests invoke every available surface without hiding calls.""" + owners = _explicit_test_owners() + missing = {} + for routine, [(test_name, path)] in owners.items(): + expected_surfaces = {"prik_lapack", "scipy_lapack"} + if routine not in F2PY_EXPORT_LIMITATIONS: + expected_surfaces.add("f2py_lapack") + visible = _visible_wrapper_calls(path, test_name, routine) + if visible != expected_surfaces: + missing[routine] = sorted(expected_surfaces - visible) + assert missing == {} + + +def test_documented_coverage_claims_match_inventory(): + """Published claims are derived from the reviewed inventory.""" + readme = " ".join((EXAMPLE_ROOT / "README.md").read_text(encoding="utf-8").split()) + assert len(EXPLICIT_TEST_NAMES) == len(ROUTINES) + assert f"PRIK wraps all {EXPECTED_LAPACK_PROCEDURES:,} discovered procedures" in readme + assert f"the {len(ROUTINES)} `float64` routines" in readme + assert f"raw f2py supports {len(ROUTINES) - len(F2PY_EXPORT_LIMITATIONS)}" in readme + assert f"All {len(EXPLICIT_TEST_NAMES)} selected routines have explicit correctness tests" in readme + assert f"The {len(F2PY_INOUT_ARGUMENTS)} scalar-writeback routines" in readme + assert f"owns {EXPECTED_LAPACK_SOURCE_FILES:,} LAPACK implementation sources" in readme + assert "no unsupported or skipped routines" in readme + + +def test_selected_routines_are_exported_by_prik(prik_lapack): + """The complete PRIK wrapper must export every selected routine.""" + missing = [name for name in ROUTINES if not hasattr(prik_lapack, name)] + assert missing == [] + + +def test_expected_f2py_routines_are_exported(f2py_lapack): + """Only reproduced and documented f2py limitations may lack an export.""" + assert getattr(f2py_lapack, "la_constants", None) is not None + expected = [name for name in ROUTINES if name not in F2PY_EXPORT_LIMITATIONS] + missing = [name for name in expected if not hasattr(f2py_lapack, name)] + assert missing == [] + unexpected = [name for name in F2PY_EXPORT_LIMITATIONS if hasattr(f2py_lapack, name)] + assert unexpected == [] diff --git a/examples/lapack/tests/test_svd.py b/examples/lapack/tests/test_svd.py new file mode 100644 index 000000000..b73603fbb --- /dev/null +++ b/examples/lapack/tests/test_svd.py @@ -0,0 +1,263 @@ +"""Singular-value-decomposition correctness tests.""" + +from __future__ import annotations + +import numpy as np +import pytest + +from .helpers import assert_allclose_float64, assert_orthogonal, column_major + + +pytestmark = [pytest.mark.fortran_end_to_end, pytest.mark.real_library] + + +def test_dgejsv_reconstructs_matrix_with_jacobi_svd(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.diag([3.0, 2.0]).astype(np.float64, order="F") + prik_a, f2py_a = matrix.copy(order="F"), matrix.copy(order="F") + prik_s, f2py_s = np.empty(2), np.empty(2) + prik_u, f2py_u = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + prik_v, f2py_v = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dgejsv( + "A", + "U", + "V", + "N", + "N", + "N", + np.int32(2), + np.int32(2), + prik_a, + np.int32(2), + prik_s, + prik_u, + np.int32(2), + prik_v, + np.int32(2), + np.empty(128), + np.int32(128), + np.empty(16, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgejsv( + b"A", + b"U", + b"V", + b"N", + b"N", + b"N", + 2, + f2py_a, + f2py_s, + f2py_u, + f2py_v, + np.empty(128), + np.empty(16, dtype=np.int32), + 0, + ) + scipy_s, scipy_u, scipy_v, _work, _iwork, scipy_info = scipy_lapack.dgejsv( + matrix.copy(order="F"), joba=4, jobu=0, jobv=0, jobr=1, jobt=0, jobp=1, lwork=128 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for values, u, v in ((prik_s, prik_u, prik_v), (f2py_s, f2py_u, f2py_v), (scipy_s, scipy_u, scipy_v)): + assert_allclose_float64(values, [3.0, 2.0], operation_size=2) + assert_orthogonal(u) + assert_orthogonal(v) + assert_allclose_float64(u @ np.diag(values) @ v.T, matrix, operation_size=2) + + +def test_dgesdd_reconstructs_matrix_with_divide_and_conquer_svd(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 7.0]], dtype=np.float64) + prik_a, f2py_a = column_major(matrix), column_major(matrix) + prik_s, f2py_s = np.empty(2), np.empty(2) + prik_u, f2py_u = np.empty((3, 3), order="F"), np.empty((3, 3), order="F") + prik_vt, f2py_vt = np.empty((2, 2), order="F"), np.empty((2, 2), order="F") + + prik_scalars = prik_lapack.dgesdd( + "A", + np.int32(3), + np.int32(2), + prik_a, + np.int32(3), + prik_s, + prik_u, + np.int32(3), + prik_vt, + np.int32(2), + np.empty(128), + np.int32(128), + np.empty(16, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgesdd( + b"A", 3, 2, f2py_a, f2py_s, f2py_u, f2py_vt, np.empty(128), 128, np.empty(16, dtype=np.int32), 0 + ) + scipy_u, scipy_s, scipy_vt, scipy_info = scipy_lapack.dgesdd( + matrix.copy(order="F"), compute_uv=1, full_matrices=1, lwork=128 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for u, values, vt in ((prik_u, prik_s, prik_vt), (f2py_u, f2py_s, f2py_vt), (scipy_u, scipy_s, scipy_vt)): + assert_orthogonal(u) + assert_orthogonal(vt.T) + assert_allclose_float64(u[:, :2] @ np.diag(values) @ vt, matrix, operation_size=3) + assert_allclose_float64(prik_s, scipy_s, operation_size=3) + assert_allclose_float64(f2py_s, scipy_s, operation_size=3) + + +def test_dgesvd_reconstructs_matrix(prik_lapack, scipy_lapack, f2py_lapack): + matrix = np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 7.0]], dtype=np.float64) + prik_a, f2py_a = column_major(matrix), column_major(matrix) + prik_s, f2py_s = np.empty(2, dtype=np.float64), np.empty(2, dtype=np.float64) + prik_u, f2py_u = column_major(np.zeros((3, 3))), column_major(np.zeros((3, 3))) + prik_vt, f2py_vt = column_major(np.zeros((2, 2))), column_major(np.zeros((2, 2))) + + prik_scalars = prik_lapack.dgesvd( + "A", + "A", + np.int32(3), + np.int32(2), + prik_a, + np.int32(3), + prik_s, + prik_u, + np.int32(3), + prik_vt, + np.int32(2), + np.empty(32), + np.int32(32), + np.int32(0), + ) + f2py_result = f2py_lapack.dgesvd(b"A", b"A", 3, 2, f2py_a, f2py_s, f2py_u, f2py_vt, np.empty(32), 32, 0) + scipy_u, scipy_s, scipy_vt, scipy_info = scipy_lapack.dgesvd( + matrix.copy(order="F"), compute_uv=1, full_matrices=1, lwork=32 + ) + + assert prik_scalars == (3, 2, 3, 3, 2, 32, 0) + assert f2py_result is None + assert scipy_info == 0 + for u, values, vt in ( + (prik_u, prik_s, prik_vt), + (f2py_u, f2py_s, f2py_vt), + (scipy_u, scipy_s, scipy_vt), + ): + assert np.all(np.diff(values) <= 0.0) + assert_orthogonal(u) + assert_orthogonal(vt.T) + assert_allclose_float64(u[:, :2] @ np.diag(values) @ vt, matrix, operation_size=3) + assert_allclose_float64(prik_s, scipy_s, operation_size=3) + assert_allclose_float64(f2py_s, scipy_s, operation_size=3) + + +def test_dorcsd_decomposes_partitioned_orthogonal_matrix(prik_lapack, scipy_lapack, f2py_lapack): + x11 = np.array([[1.0]], dtype=np.float64, order="F") + x12 = np.array([[0.0]], dtype=np.float64, order="F") + x21 = np.array([[0.0]], dtype=np.float64, order="F") + x22 = np.array([[1.0]], dtype=np.float64, order="F") + prik_blocks = [block.copy(order="F") for block in (x11, x12, x21, x22)] + f2py_blocks = [block.copy(order="F") for block in (x11, x12, x21, x22)] + prik_theta, f2py_theta = np.empty(1), np.empty(1) + prik_u1, prik_u2, prik_v1t, prik_v2t = (np.empty((1, 1), order="F") for _ in range(4)) + f2py_u1, f2py_u2, f2py_v1t, f2py_v2t = (np.empty((1, 1), order="F") for _ in range(4)) + + prik_scalars = prik_lapack.dorcsd( + "Y", + "Y", + "Y", + "Y", + "N", + "O", + np.int32(2), + np.int32(1), + np.int32(1), + prik_blocks[0], + np.int32(1), + prik_blocks[1], + np.int32(1), + prik_blocks[2], + np.int32(1), + prik_blocks[3], + np.int32(1), + prik_theta, + prik_u1, + np.int32(1), + prik_u2, + np.int32(1), + prik_v1t, + np.int32(1), + prik_v2t, + np.int32(1), + np.empty(128), + np.int32(128), + np.empty(16, dtype=np.int32), + np.int32(0), + ) + f2py_result = f2py_lapack.dorcsd( + b"Y", + b"Y", + b"Y", + b"Y", + b"N", + b"O", + 2, + 1, + 1, + f2py_blocks[0], + f2py_blocks[1], + f2py_blocks[2], + f2py_blocks[3], + f2py_theta, + f2py_u1, + f2py_u2, + f2py_v1t, + f2py_v2t, + np.empty(128), + 128, + np.empty(16, dtype=np.int32), + 0, + ) + _c11, _c12, _c21, _c22, scipy_theta, scipy_u1, scipy_u2, scipy_v1t, scipy_v2t, scipy_info = scipy_lapack.dorcsd( + x11, x12, x21, x22, compute_u1=1, compute_u2=1, compute_v1t=1, compute_v2t=1, trans=0, signs=0, lwork=128 + ) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + for theta, u1, u2, v1t, v2t in ( + (prik_theta, prik_u1, prik_u2, prik_v1t, prik_v2t), + (f2py_theta, f2py_u1, f2py_u2, f2py_v1t, f2py_v2t), + (scipy_theta, scipy_u1, scipy_u2, scipy_v1t, scipy_v2t), + ): + cosine = np.array([[np.cos(theta[0])]]) + assert_allclose_float64(theta, [0.0]) + assert_allclose_float64(u1 @ cosine @ v1t, x11) + assert_allclose_float64(u2 @ cosine @ v2t, x22) + + +def test_dlasd4_solves_rank_one_secular_equation(prik_lapack, scipy_lapack, f2py_lapack): + diagonal = np.array([1.0, 3.0], dtype=np.float64) + update = np.array([0.6, 0.8], dtype=np.float64) + rho = 1.0 + expected = float(np.sqrt(np.linalg.eigvalsh(np.diag(diagonal * diagonal) + rho * np.outer(update, update))[0])) + prik_delta, f2py_delta = np.empty(2), np.empty(2) + prik_work, f2py_work = np.empty(2), np.empty(2) + + prik_scalars = prik_lapack.dlasd4( + np.int32(2), np.int32(1), diagonal, update, prik_delta, np.float64(rho), np.float64(0.0), prik_work, np.int32(0) + ) + f2py_result = f2py_lapack.dlasd4(2, 1, diagonal, update, f2py_delta, rho, 0.0, f2py_work, 0) + scipy_delta, scipy_sigma, scipy_work, scipy_info = scipy_lapack.dlasd4(0, diagonal, update, rho=rho) + + assert f2py_result is None + assert prik_scalars[-1] == scipy_info == 0 + prik_sigma = prik_scalars[-2] + assert_allclose_float64(prik_sigma, expected, operation_size=2) + assert_allclose_float64(scipy_sigma, expected, operation_size=2) + assert_allclose_float64(prik_delta, diagonal - prik_sigma) + assert_allclose_float64(prik_work, diagonal + prik_sigma) + assert_allclose_float64(f2py_delta, scipy_delta) + assert_allclose_float64(f2py_work, scipy_work) + secular = 1.0 + rho * np.sum(update * update / (diagonal * diagonal - prik_sigma * prik_sigma)) + assert_allclose_float64(secular, 0.0, operation_size=2) diff --git a/examples/native_library.py b/examples/native_library.py new file mode 100644 index 000000000..3cefd1053 --- /dev/null +++ b/examples/native_library.py @@ -0,0 +1,334 @@ +"""Build one reusable native BLAS or LAPACK library from the copied examples.""" + +from __future__ import annotations + +import argparse +import concurrent.futures +from dataclasses import dataclass +import hashlib +import os +from pathlib import Path +import shutil +import subprocess +import sys +import sysconfig +from collections.abc import Sequence + + +EXAMPLES_ROOT = Path(__file__).resolve().parent +BLAS_SOURCE_ROOT = EXAMPLES_ROOT / "blas" / "native" +LAPACK_SOURCE_ROOT = EXAMPLES_ROOT / "lapack" / "native" +NATIVE_CACHE_ENV = "PRIK_REAL_LIBRARY_NATIVE_CACHE_DIR" +NATIVE_JOBS_ENV = "PRIK_REAL_LIBRARY_NATIVE_JOBS" +NATIVE_CACHE_VERSION = "copyable-examples-v3-link-dependencies" +NATIVE_MODULE_SOURCE_STEMS = frozenset({"la_constants", "la_xisnan"}) +NATIVE_LINK_DEPENDENCIES = { + "blas": (), + "lapack": ("-llapack", "-lblas"), +} +DEFAULT_NATIVE_COMPILE_JOB_LIMIT = 8 +FORTRAN_SUFFIXES = frozenset({".f", ".f90", ".f95", ".f03", ".f08", ".for", ".f77", ".ftn"}) +SUPPORTED_LIBRARIES = ("blas", "lapack") + + +@dataclass(frozen=True) +class NativeLibrary: + """A complete native library compiled once for both wrapper generators.""" + + name: str + shared_library: Path + archive: Path + cache_dir: Path + module_dir: Path + sources: tuple[Path, ...] + compiler: str + + +def require_tool(name: str) -> str: + """Return an executable path or explain the missing example prerequisite.""" + executable = shutil.which(name) + if executable is None: + raise RuntimeError(f"{name} is required to build the native-library examples") + return executable + + +def compiler_identity(compiler: str) -> str: + """Return the resolved compiler path and its first version line.""" + result = subprocess.run( # nosec B603 - explicit local compiler identity probe + (compiler, "--version"), + capture_output=True, + text=True, + check=False, + ) + first_line = result.stdout.splitlines()[0] if result.stdout else compiler + return f"{Path(compiler).resolve()}: {first_line}" + + +def library_sources(library: str) -> tuple[Path, ...]: + """Return the authoritative implementation sources for one named library.""" + if library not in SUPPORTED_LIBRARIES: + raise ValueError(f"unknown reference library {library!r}; choose from {', '.join(SUPPORTED_LIBRARIES)}") + root = BLAS_SOURCE_ROOT if library == "blas" else LAPACK_SOURCE_ROOT + return tuple(sorted(path for path in root.iterdir() if path.is_file() and path.suffix.lower() in FORTRAN_SUFFIXES)) + + +def native_sources(library: str) -> tuple[Path, ...]: + """Return sources in a safe compilation order, including LAPACK's BLAS dependencies.""" + if library not in SUPPORTED_LIBRARIES: + return library_sources(library) + if library == "blas": + return library_sources("blas") + lapack_sources = library_sources("lapack") + module_sources = tuple( + source + for source in ( + LAPACK_SOURCE_ROOT / "la_constants.f90", + LAPACK_SOURCE_ROOT / "la_xisnan.F90", + ) + if source.is_file() + ) + module_source_set = set(module_sources) + lapack_rest = tuple(source for source in lapack_sources if source not in module_source_set) + lapack_stems = {source.stem.lower() for source in lapack_sources} + blas_dependencies = tuple(source for source in library_sources("blas") if source.stem.lower() not in lapack_stems) + return (*module_sources, *lapack_rest, *blas_dependencies) + + +def native_cache_root() -> Path: + """Return the configured cache, or a build directory inside the copied examples.""" + configured = os.environ.get(NATIVE_CACHE_ENV) + if configured: + return Path(configured).expanduser().resolve() + return EXAMPLES_ROOT / ".build" / "native" + + +def native_compile_jobs() -> int: + """Return the validated native compilation parallelism.""" + configured = os.environ.get(NATIVE_JOBS_ENV) + if configured: + try: + jobs = int(configured) + except ValueError as error: + raise ValueError(f"{NATIVE_JOBS_ENV} must be a positive integer, got {configured!r}") from error + if jobs < 1: + raise ValueError(f"{NATIVE_JOBS_ENV} must be a positive integer, got {configured!r}") + return jobs + return max(1, min(os.cpu_count() or 1, DEFAULT_NATIVE_COMPILE_JOB_LIMIT)) + + +def _native_platform_identity() -> str: + return f"{sysconfig.get_platform()}:{os.name}:{sys.maxsize}" + + +def _source_digest(source: Path) -> str: + digest = hashlib.sha256() + with source.open("rb") as stream: + for chunk in iter(lambda: stream.read(1024 * 1024), b""): + digest.update(chunk) + return digest.hexdigest() + + +def _native_cache_key(library: str, compiler: str, sources: tuple[Path, ...]) -> str: + digest = hashlib.sha256() + for value in (NATIVE_CACHE_VERSION, library, compiler_identity(compiler), _native_platform_identity()): + digest.update(value.encode()) + digest.update(b"\0") + for source in sources: + digest.update(source.relative_to(EXAMPLES_ROOT).as_posix().encode()) + digest.update(b":") + digest.update(_source_digest(source).encode()) + digest.update(b"\0") + return digest.hexdigest()[:24] + + +def _cached_object_path(objects_dir: Path, source: Path) -> Path: + return objects_dir / source.relative_to(EXAMPLES_ROOT).with_suffix(".o") + + +def _compile_source(compiler: str, source: Path, native_object: Path, module_dir: Path) -> None: + native_object.parent.mkdir(parents=True, exist_ok=True) + subprocess.run( # nosec B603 - explicit compiler and copied example source + ( + compiler, + "-O0", + "-fPIC", + "-c", + str(source), + "-o", + str(native_object), + "-J", + str(module_dir), + "-I", + str(module_dir), + ), + check=True, + ) + + +def _compile_independent_sources( + compiler: str, + sources: tuple[Path, ...], + objects_dir: Path, + module_dir: Path, + jobs: int, +) -> None: + if not sources: + return + with concurrent.futures.ThreadPoolExecutor(max_workers=min(jobs, len(sources))) as executor: + futures = [ + executor.submit( + _compile_source, + compiler, + source, + _cached_object_path(objects_dir, source), + module_dir, + ) + for source in sources + ] + for future in concurrent.futures.as_completed(futures): + future.result() + + +def _cached_objects( + cache_dir: Path, + sources: tuple[Path, ...], + compiler: str, + jobs: int, +) -> tuple[Path, ...]: + objects_dir = cache_dir / "objects" + modules_dir = cache_dir / "modules" + complete = cache_dir / "objects.complete" + objects = tuple(_cached_object_path(objects_dir, source) for source in sources) + module_sources = tuple(source for source in sources if source.stem.lower() in NATIVE_MODULE_SOURCE_STEMS) + modules = tuple(modules_dir / f"{source.stem.lower()}.mod" for source in module_sources) + if ( + complete.is_file() + and modules_dir.is_dir() + and all(native_object.is_file() for native_object in objects) + and all(module.is_file() for module in modules) + ): + return objects + + process_suffix = str(os.getpid()) + temporary_objects = cache_dir / f"objects.{process_suffix}.tmp" + temporary_modules = cache_dir / f"modules.{process_suffix}.tmp" + shutil.rmtree(temporary_objects, ignore_errors=True) + shutil.rmtree(temporary_modules, ignore_errors=True) + temporary_objects.mkdir(parents=True) + temporary_modules.mkdir(parents=True) + module_source_set = set(module_sources) + independent_sources = tuple(source for source in sources if source not in module_source_set) + for source in module_sources: + _compile_source(compiler, source, _cached_object_path(temporary_objects, source), temporary_modules) + _compile_independent_sources(compiler, independent_sources, temporary_objects, temporary_modules, jobs) + shutil.rmtree(objects_dir, ignore_errors=True) + temporary_objects.rename(objects_dir) + shutil.rmtree(modules_dir, ignore_errors=True) + temporary_modules.rename(modules_dir) + complete.write_text(f"{NATIVE_CACHE_VERSION}\n", encoding="utf-8") + (cache_dir / "archive.complete").unlink(missing_ok=True) + (cache_dir / "shared.complete").unlink(missing_ok=True) + return tuple(_cached_object_path(objects_dir, source) for source in sources) + + +def _cached_archive(cache_dir: Path, library: str, objects: tuple[Path, ...], archiver: str) -> Path: + archive = cache_dir / f"libprik_full_{library}.a" + complete = cache_dir / "archive.complete" + if complete.is_file() and archive.is_file(): + return archive + temporary_archive = cache_dir / f"{archive.name}.{os.getpid()}.tmp" + temporary_archive.unlink(missing_ok=True) + subprocess.run( # nosec B603 - explicit archiver and compiled example objects + (archiver, "rcs", str(temporary_archive), *(str(native_object) for native_object in objects)), + check=True, + ) + os.replace(temporary_archive, archive) + complete.write_text(f"{NATIVE_CACHE_VERSION}\n", encoding="utf-8") + return archive + + +def _cached_shared_library(cache_dir: Path, library: str, archive: Path, compiler: str) -> Path: + shared_library = cache_dir / f"libprik_full_{library}.so" + complete = cache_dir / "shared.complete" + if complete.is_file() and shared_library.is_file(): + return shared_library + temporary_shared = cache_dir / f"{shared_library.name}.{os.getpid()}.tmp" + temporary_shared.unlink(missing_ok=True) + subprocess.run( # nosec B603 - explicit compiler and compiled example archive + ( + compiler, + "-shared", + "-o", + str(temporary_shared), + "-Wl,--whole-archive", + str(archive), + "-Wl,--no-whole-archive", + *NATIVE_LINK_DEPENDENCIES[library], + ), + check=True, + ) + os.replace(temporary_shared, shared_library) + complete.write_text(f"{NATIVE_CACHE_VERSION}\n", encoding="utf-8") + return shared_library + + +def build_reference_library( + library: str, + *, + cache_root: Path | None = None, + compiler: str | None = None, + archiver: str | None = None, + jobs: int | None = None, +) -> NativeLibrary: + """Build on a cache miss and return one complete reusable native library.""" + selected_compiler = compiler or require_tool("gfortran") + selected_archiver = archiver or require_tool("ar") + selected_sources = native_sources(library) + selected_jobs = jobs if jobs is not None else native_compile_jobs() + if selected_jobs < 1: + raise ValueError(f"jobs must be a positive integer, got {selected_jobs!r}") + selected_cache_root = (cache_root or native_cache_root()).resolve() + cache_dir = selected_cache_root / f"{library}-{_native_cache_key(library, selected_compiler, selected_sources)}" + cache_dir.mkdir(parents=True, exist_ok=True) + objects = _cached_objects(cache_dir, selected_sources, selected_compiler, selected_jobs) + archive = _cached_archive(cache_dir, library, objects, selected_archiver) + shared_library = _cached_shared_library(cache_dir, library, archive, selected_compiler) + return NativeLibrary( + name=library, + shared_library=shared_library, + archive=archive, + cache_dir=cache_dir, + module_dir=cache_dir / "modules", + sources=selected_sources, + compiler=selected_compiler, + ) + + +def linker_name(shared_library: Path) -> str: + """Return the `-l` name for a shared library produced by this module.""" + name = shared_library.name + if not name.startswith("lib") or ".so" not in name: + raise ValueError(f"expected a lib*.so native library, got {shared_library}") + return name[3 : name.index(".so")] + + +def main(argv: Sequence[str] | None = None) -> int: + """Build a copied example's native library and print its reusable path.""" + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("library", choices=SUPPORTED_LIBRARIES) + parser.add_argument("--cache-dir", type=Path, default=None) + parser.add_argument("--compiler", default=None) + parser.add_argument("--jobs", type=int, default=None) + args = parser.parse_args(argv) + build = build_reference_library( + args.library, + cache_root=args.cache_dir, + compiler=args.compiler, + jobs=args.jobs, + ) + print(build.shared_library) + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/prik/cli.py b/prik/cli.py index 38ebd2c3a..f5c6ecac7 100644 --- a/prik/cli.py +++ b/prik/cli.py @@ -881,7 +881,8 @@ def _wrapper_build_uses_pyi_contract(args: argparse.Namespace) -> bool: def _native_link_options_used(args: argparse.Namespace) -> bool: return bool( - getattr(args, "native_fortran_sources", None) + getattr(args, "no_compile_input_sources", False) + or getattr(args, "native_fortran_sources", None) or getattr(args, "native_compile_flags", None) or getattr(args, "native_objects", None) or getattr(args, "native_libraries", None) @@ -890,6 +891,14 @@ def _native_link_options_used(args: argparse.Namespace) -> bool: ) +def _prebuilt_native_link_input_used(args: argparse.Namespace) -> bool: + return bool( + getattr(args, "native_objects", None) + or getattr(args, "native_libraries", None) + or getattr(args, "native_link_items", None) + ) + + def _wrapper_compile_options_used(args: argparse.Namespace) -> bool: return bool( getattr(args, "wrapper_compiler_debug", False) @@ -914,6 +923,8 @@ def _validate_pyi_wrapper_options(args: argparse.Namespace, parser: argparse.Arg parser.error("A .pyi wrapper build cannot mix positional native sources; pass native artifacts with flags") if len(args.paths) != 1: parser.error("A .pyi wrapper build accepts exactly one entry contract") + if getattr(args, "no_compile_input_sources", False): + parser.error("--no-compile-input-sources applies only to source-driven wrapper builds") if not ( getattr(args, "native_fortran_sources", None) or getattr(args, "native_objects", None) @@ -953,15 +964,23 @@ def _validate_manifest_wrapper_options(args: argparse.Namespace, parser: argpars def _validate_source_wrapper_options(args: argparse.Namespace, parser: argparse.ArgumentParser) -> None: if not args.paths: - parser.error("A wrapper build expects at least one Fortran source file or a semantic .pyi contract") - if any(Path(path).is_dir() for path in args.paths): - parser.error("A wrapper build expects Fortran source files, not directories") - unsupported = [path for path in args.paths if not _path_is_fortran_source(path)] + parser.error("A wrapper build expects at least one Fortran source, source directory, or semantic .pyi contract") + unsupported = [path for path in args.paths if not Path(path).is_dir() and not _path_is_fortran_source(path)] if unsupported: parser.error( "A wrapper build expects recognized Fortran source suffixes or one semantic .pyi contract; " f"unsupported input: {unsupported[0]}" ) + empty_directories = [path for path in args.paths if Path(path).is_dir() and not _collect_extensions(Path(path))] + if empty_directories: + parser.error(f"A wrapper build found no recognized Fortran sources under: {empty_directories[0]}") + if not getattr(args, "no_compile_input_sources", False): + return + if not (getattr(args, "native_fortran_sources", None) or _prebuilt_native_link_input_used(args)): + parser.error( + "--no-compile-input-sources requires --native-fortran-sources, --native-objects, " + "--native-library, or --native-link-item" + ) def _validate_wrapper_out(args: argparse.Namespace, parser: argparse.ArgumentParser) -> None: @@ -1282,6 +1301,7 @@ def record_total_build_time(elapsed: float) -> None: output_name=_wrapper_output_name(args), preprocessing=preprocessing, strict_wrapper_names=getattr(args, "strict_wrapper_names", False), + compile_input_sources=not getattr(args, "no_compile_input_sources", False), native_fortran_sources=getattr(args, "native_fortran_sources", None), native_fortran_flags=_cli_native_compile_flags(getattr(args, "native_compile_flags", None)), native_objects=getattr(args, "native_objects", None), @@ -1805,6 +1825,11 @@ def _add_build_manifest_option( def _add_native_compilation_options(group: argparse._ArgumentGroup) -> None: + group.add_argument( + "--no-compile-input-sources", + action="store_true", + help="Read positional Fortran sources without compiling them; require an explicit native implementation", + ) group.add_argument( "--native-fortran-sources", dest="native_fortran_sources", @@ -1901,6 +1926,7 @@ def _add_diagnostic_controls(group: argparse._ArgumentGroup, *, allow_verbose: b "print_limit": None, "vars_limit": None, "build_manifest": None, + "no_compile_input_sources": False, "native_fortran_sources": None, "native_compile_flags": None, "jobs": None, @@ -1935,7 +1961,7 @@ def _add_build_arguments(parser: argparse.ArgumentParser) -> None: _add_paths( positional_group, metavar="INPUT", - help_text="Fortran source file(s), or exactly one semantic .pyi contract", + help_text="Fortran source file(s), one source directory, or exactly one semantic .pyi contract", ) input_group = parser.add_argument_group("input selection") _add_language_option( @@ -1943,6 +1969,7 @@ def _add_build_arguments(parser: argparse.ArgumentParser) -> None: choices=("fortran",), help_text="Input language (default: fortran)", ) + parser.set_defaults(language="fortran") _add_build_manifest_option(input_group) output_group = parser.add_argument_group("output options") diff --git a/prik/parsers/fortran/parser.py b/prik/parsers/fortran/parser.py index 58d513d73..e9bbd1a3a 100644 --- a/prik/parsers/fortran/parser.py +++ b/prik/parsers/fortran/parser.py @@ -995,12 +995,7 @@ def _helper_index_project_file(self, project: FortranProject, parsed_file: Fortr for program in parsed_file.programs: self._helper_index_project_program(project, program) for procedure in parsed_file.procedures: - self._insert_unique_scope_symbol( - project.procedures, - procedure.name.lower(), - procedure, - label="project procedure scope", - ) + self._helper_index_project_standalone_procedure(project, procedure) for dtype in parsed_file.derived_types: self._insert_unique_scope_symbol( project.derived_types, @@ -1061,6 +1056,24 @@ def _helper_index_project_owner_members( for interface in owner.interfaces: self._helper_index_project_interface(project, interface, owner_key) + def _helper_index_project_standalone_procedure( + self, + project: FortranProject, + procedure: FortranProcedureSignature, + ) -> None: + """Index a standalone procedure ahead of any unqualified owner alias.""" + procedure_key = procedure.name.lower() + existing = project.procedures.get(procedure_key) + if existing is not None and existing.module is not None: + project.procedures[procedure_key] = procedure + return + self._insert_unique_scope_symbol( + project.procedures, + procedure_key, + procedure, + label="project procedure scope", + ) + def _helper_index_project_program(self, project: FortranProject, program: FortranProgram) -> None: """Index one named program and its module dependencies.""" if not program.name: @@ -3532,7 +3545,7 @@ def _normalize_declared_name(name: str, meta: dict) -> str: def _strip_legacy_star_kind_prefix(left: str) -> str: """Remove an intrinsic `type*kind` prefix from a legacy declaration.""" return re.sub( - r"^(integer|real|complex|logical)\s*\*\s*[0-9]+\s*", + r"^(integer|real|complex|logical|character)\s*\*\s*[0-9]+\s*", "", left, flags=re.IGNORECASE, diff --git a/prik/pipeline/build.py b/prik/pipeline/build.py index 88e704988..a5b1a1cb8 100644 --- a/prik/pipeline/build.py +++ b/prik/pipeline/build.py @@ -802,13 +802,28 @@ def _project_compile_batches( def _source_paths(sources: str | Path | Iterable[str | Path]) -> tuple[Path, ...]: - paths = (Path(sources),) if isinstance(sources, str | Path) else tuple(Path(source) for source in sources) - if not paths: - raise ValueError("wrapper build requires at least one Fortran source file") - for path in paths: + inputs = (Path(sources),) if isinstance(sources, str | Path) else tuple(Path(source) for source in sources) + if not inputs: + raise ValueError("wrapper build requires at least one Fortran source file or directory") + + paths: list[Path] = [] + for path in inputs: + if path.is_dir(): + discovered = sorted( + candidate + for candidate in path.rglob("*") + if candidate.is_file() and candidate.suffix.lower() in _FORTRAN_SOURCE_SUFFIXES + ) + if not discovered: + raise ValueError(f"No recognized Fortran sources found under: {path}") + paths.extend(discovered) + continue if not path.is_file(): raise FileNotFoundError(f"Fortran source not found: {path}") - return paths + if path.suffix.lower() not in _FORTRAN_SOURCE_SUFFIXES: + raise ValueError(f"Unrecognized Fortran source suffix: {path}") + paths.append(path) + return tuple(dict.fromkeys(paths)) def _wrapper_output_paths(output_dir: str | Path | None) -> tuple[Path, Path]: @@ -1341,7 +1356,7 @@ def _native_build_inputs( and not complete_link_items ): raise ValueError( - ".pyi wrapper build requires at least one native source, object, archive, shared library, " + "Wrapper build requires at least one native source, object, archive, shared library, " "ordered link item, or -l name" ) return _NativeBuildInputs( @@ -1913,6 +1928,7 @@ def build_fortran_extension( fortran_type_probe_runner: list[str] | None = None, fortran_type_probe_cache_dir: str | Path | None = None, refresh_fortran_type_probe: bool = False, + compile_input_sources: bool = True, native_fortran_sources: Iterable[str | Path] | None = None, native_fortran_flags: Iterable[str] | None = None, native_objects: Iterable[str | Path] | None = None, @@ -1946,8 +1962,10 @@ def build_fortran_extension( output_path.mkdir(parents=True, exist_ok=True) preprocessing = preprocessing or _default_preprocessing_config() supplemental_source_paths = tuple(Path(path) for path in (native_fortran_sources or ())) + input_implementation_paths = source_paths if compile_input_sources else () + implementation_source_paths = (*input_implementation_paths, *supplemental_source_paths) native_inputs = _native_build_inputs( - native_fortran_sources=(*source_paths, *supplemental_source_paths), + native_fortran_sources=implementation_source_paths, native_fortran_flags=native_fortran_flags, native_objects=native_objects, native_libraries=native_libraries, @@ -2018,7 +2036,7 @@ def build_fortran_extension( library_dirs=native_inputs.library_dirs, explicit_include_dirs=native_inputs.explicit_include_dirs, include_dirs=include_dirs, - module_dir=output_path, + module_dir=output_path if native_source_objects else None, ) _validate_native_link_paths(native_build_plan) native_compile_batches = _project_compile_batches(parsed, native_source_objects) diff --git a/prik/semantics/README.md b/prik/semantics/README.md index 3f38dd30c..78e3f06e2 100644 --- a/prik/semantics/README.md +++ b/prik/semantics/README.md @@ -55,6 +55,9 @@ address- or handle-based. Public syntax uses the Python boundary shape directly, keeps `Final[T]` for module constants, and requires hidden native literals inside `@native_call` to be typed expressions such as `Int32(1)` or `String[1]("N")`. +Completed module-variable policy selects direct binding materialization for a +literal constant and a read-only native getter for a symbolic numeric source +parameter. `ir2ast.py`, bridges, and bindings consume those decisions instead of making local policy guesses. Bridge and binding dispatch is strict: diff --git a/prik/semantics/wrapper_policy.py b/prik/semantics/wrapper_policy.py index 896d1e4b1..1d821bada 100644 --- a/prik/semantics/wrapper_policy.py +++ b/prik/semantics/wrapper_policy.py @@ -242,6 +242,7 @@ class ModuleGetterAction(str, Enum): """Completed Python-visible read behavior for a module variable.""" CONSTANT_VALUE = "constant_value" + NATIVE_CONSTANT_VALUE = "native_constant_value" DIRECT_VALUE = "direct_value" NULLABLE_SNAPSHOT = "nullable_snapshot" BORROWED_ARRAY_VIEW = "borrowed_array_view" @@ -1981,11 +1982,19 @@ def _scalar_module_variable_policy( constant: bool, ) -> ModuleVariablePolicy: """Build one scalar value, snapshot, or constant module policy.""" - blockers = _scalar_module_variable_blockers(variable, getter, setter, descriptor_kind, constant) + getter_action = _scalar_module_getter_action(variable, getter, constant) + blockers = _scalar_module_variable_blockers( + variable, + getter, + setter, + descriptor_kind, + constant, + getter_action, + ) initializer = variable.metadata.get(models.RESOLVED_MODULE_VARIABLE_INITIALIZER_METADATA) return ModuleVariablePolicy( **_module_variable_policy_base(variable, module_name, owner_path), - getter_action=_scalar_module_getter_action(getter, constant), + getter_action=getter_action, getter=getter, setter_action=setter.setter_action if setter is not None else SetterAction.OMIT, native_assignment=_scalar_module_native_assignment(setter), @@ -1996,7 +2005,7 @@ def _scalar_module_variable_policy( ), constant_value=( _scalar_module_literal_value(variable.default_value, variable.semantic_type.name) - if constant and variable.default_value is not None + if getter_action is ModuleGetterAction.CONSTANT_VALUE and variable.default_value is not None else None ), supported=not blockers, @@ -5694,33 +5703,93 @@ def _scalar_module_variable_blockers( setter: OwnershipDecision | None, descriptor_kind: str | None, constant: bool, + getter_action: ModuleGetterAction, ) -> list[str]: """Return Phase 4 blockers for one module variable.""" blockers = [] if variable.visibility != "public": blockers.append("module variable is not public") - if not _is_first_lane_scalar_type(variable.semantic_type): + blockers.extend(_scalar_module_getter_blockers(variable, getter, getter_action)) + blockers.extend(_scalar_module_optional_setter_blockers(setter, descriptor_kind, constant)) + blockers.extend(_scalar_module_constant_value_blockers(variable, getter_action)) + blockers.extend(_scalar_module_initializer_blockers(variable, setter)) + return blockers + + +def _scalar_module_getter_blockers( + variable: models.SemanticVariable, + getter: OwnershipDecision | None, + getter_action: ModuleGetterAction, +) -> tuple[str, ...]: + """Validate one completed scalar or literal-string getter.""" + blockers = [] + literal_string = _is_binding_literal_string(variable, getter_action) + if not (_is_first_lane_scalar_type(variable.semantic_type) or literal_string): blockers.append("module variable is not a primitive rank-zero scalar") + expected_getter_kind = ObjectKind.STRING if literal_string else ObjectKind.SCALAR + supported_getter_actions = ( + {CodegenAction.COPY_OUT} if literal_string else {CodegenAction.DIRECT_VALUE, CodegenAction.SNAPSHOT_COPY} + ) if getter is None: blockers.append("module variable is missing completed getter policy") - elif getter.is_blocked or getter.kind is not ObjectKind.SCALAR: + elif getter.is_blocked or getter.kind is not expected_getter_kind: blockers.append("module variable getter is not a supported scalar policy") - elif getter.codegen_action not in {CodegenAction.DIRECT_VALUE, CodegenAction.SNAPSHOT_COPY}: + elif getter.codegen_action not in supported_getter_actions: blockers.append(f"module variable getter action {getter.codegen_action.value!r} is unsupported") + return tuple(blockers) + + +def _is_binding_literal_string( + variable: models.SemanticVariable, + getter_action: ModuleGetterAction, +) -> bool: + """Return whether the binding materializes one rank-zero string literal.""" + return bool( + getter_action is ModuleGetterAction.CONSTANT_VALUE + and variable.semantic_type.name == "String" + and int(variable.semantic_type.rank or 0) == 0 + ) + + +def _scalar_module_optional_setter_blockers( + setter: OwnershipDecision | None, + descriptor_kind: str | None, + constant: bool, +) -> tuple[str, ...]: + """Validate presence and consistency of one completed scalar setter.""" if setter is None: - blockers.append("module variable is missing completed setter policy") - else: - blockers.extend(_scalar_module_setter_blockers(setter, descriptor_kind, constant)) - if constant and variable.default_value is None: - blockers.append("scalar module constant is missing its completed value") - elif constant and not _is_scalar_module_literal(variable.default_value, variable.semantic_type.name): - blockers.append("scalar module constant value is not a supported literal") + return ("module variable is missing completed setter policy",) + return _scalar_module_setter_blockers(setter, descriptor_kind, constant) + + +def _scalar_module_constant_value_blockers( + variable: models.SemanticVariable, + getter_action: ModuleGetterAction, +) -> tuple[str, ...]: + """Validate a constant only when its value is binding-owned.""" + if getter_action is not ModuleGetterAction.CONSTANT_VALUE: + return () + if variable.default_value is None: + return ("scalar module constant is missing its completed value",) + if not _is_scalar_module_literal(variable.default_value, variable.semantic_type.name): + return ("scalar module constant value is not a supported literal",) + return () + + +def _scalar_module_initializer_blockers( + variable: models.SemanticVariable, + setter: OwnershipDecision | None, +) -> tuple[str, ...]: + """Validate one optional import-time scalar initializer.""" initializer = variable.metadata.get(models.RESOLVED_MODULE_VARIABLE_INITIALIZER_METADATA) - if initializer is not None and (setter is None or setter.setter_action is not SetterAction.WRITE_THROUGH): + if initializer is None: + return () + blockers = [] + if setter is None or setter.setter_action is not SetterAction.WRITE_THROUGH: blockers.append("module variable initializer requires a write-through setter") - if initializer is not None and not _is_scalar_module_literal(initializer, variable.semantic_type.name): + if not _is_scalar_module_literal(initializer, variable.semantic_type.name): blockers.append("module variable initializer is not a supported scalar literal") - return blockers + return tuple(blockers) def _scalar_module_setter_blockers( @@ -5747,16 +5816,31 @@ def _scalar_module_setter_blockers( def _scalar_module_getter_action( + variable: models.SemanticVariable, getter: OwnershipDecision | None, constant: bool, ) -> ModuleGetterAction: if constant: + if _source_parameter_needs_native_getter(variable): + return ModuleGetterAction.NATIVE_CONSTANT_VALUE return ModuleGetterAction.CONSTANT_VALUE if getter is not None and getter.codegen_action is CodegenAction.SNAPSHOT_COPY and getter.nullable: return ModuleGetterAction.NULLABLE_SNAPSHOT return ModuleGetterAction.DIRECT_VALUE +def _source_parameter_needs_native_getter(variable: models.SemanticVariable) -> bool: + """Return whether a source parameter value remains compiler-owned.""" + return bool( + variable.origin.source_language == "fortran" + and variable.origin.source_kind == "variable" + and ( + variable.default_value is None + or not _is_scalar_module_literal(variable.default_value, variable.semantic_type.name) + ) + ) + + def _scalar_module_native_assignment( setter: OwnershipDecision | None, ) -> AssignmentMode: @@ -5798,6 +5882,8 @@ def _scalar_module_literal_value(value: object, semantic_type_name: str) -> obje return True if lowered in {".false.", "false"}: return False + if semantic_type_name == "String": + return ast.literal_eval(text) normalized = text.replace("D", "e").replace("d", "e") parsed = ast.literal_eval(normalized) if semantic_type_name in {"Complex64", "Complex128"} and isinstance(parsed, tuple): diff --git a/prik/wrapper_codegen/c/binding.py b/prik/wrapper_codegen/c/binding.py index 8ceb5e6fc..450bb80ff 100644 --- a/prik/wrapper_codegen/c/binding.py +++ b/prik/wrapper_codegen/c/binding.py @@ -13,7 +13,6 @@ SetterAction, ) from prik.semantics.wrapper_policy import ( - ArgumentConversionPhase, ArgumentHandoffMode, CallbackABIKind, CallbackResultAction, @@ -5463,6 +5462,8 @@ def _lower_module_getter(self, plan: ModuleVariablePlan) -> tuple[CFunction, ... match action: case ModuleGetterAction.CONSTANT_VALUE: return self._lower_module_getter_constant_value(plan) + case ModuleGetterAction.NATIVE_CONSTANT_VALUE: + return self._lower_module_getter_native_constant_value(plan) case ModuleGetterAction.DIRECT_VALUE: return self._lower_module_getter_direct_value(plan) case ModuleGetterAction.NULLABLE_SNAPSHOT: @@ -5479,6 +5480,10 @@ def _lower_module_getter_constant_value(self, _plan: ModuleVariablePlan) -> tupl """Constants are materialized in the module dictionary at initialization.""" return () + def _lower_module_getter_native_constant_value(self, _plan: ModuleVariablePlan) -> tuple[CFunction, ...]: + """Compiler-evaluated constants are materialized from their bridge getter.""" + return () + def _lower_module_getter_direct_value(self, plan: ModuleVariablePlan) -> tuple[CFunction, ...]: """Return a copied Python scalar from one native getter call.""" scalar_type = PrimitiveScalarTypeRegistry.type_for(plan.semantic_type_name) @@ -5993,16 +5998,12 @@ def _derived_alias_preflight_nodes( ) def _binding_conversion_order(self, plan: FunctionPlan) -> tuple[ArgumentTransferPlan, ...]: - """Apply the completed argument conversion schedule.""" - return tuple( - sorted( - plan.arguments, - key=lambda argument: ( - argument.binding.conversion_phase is ArgumentConversionPhase.DEFERRED_REPLACEMENT, - argument.python_position, - ), - ) - ) + """Apply the dependency-safe argument conversion schedule from the plan.""" + arguments = {argument.owner_path: argument for argument in plan.arguments} + try: + return tuple(arguments[owner_path] for owner_path in plan.binding.argument_conversion_order) + except KeyError as error: + raise ValueError(f"Unknown binding argument conversion owner {error.args[0]!r}") from None def _visit_ArgumentTransferPlan( self, @@ -10399,7 +10400,10 @@ def _module_variable_helper_prototypes( plan: ModuleVariablePlan, ) -> tuple[CFunctionPrototype, ...]: """Declare C helpers before the generated module-type routing code.""" - if plan.binding.getter_action is ModuleGetterAction.CONSTANT_VALUE: + if plan.binding.getter_action in { + ModuleGetterAction.CONSTANT_VALUE, + ModuleGetterAction.NATIVE_CONSTANT_VALUE, + }: return () prototypes = [CFunctionPrototype(self._module_getter_name(plan), "PyObject *", storage="static")] if plan.binding.setter_action is SetterAction.WRITE_THROUGH: @@ -10431,7 +10435,8 @@ def _module_property_support( reject_replacement=(variable.binding.setter_action is SetterAction.REJECT_REPLACEMENT), ) for variable in namespace.variables - if variable.binding.getter_action is not ModuleGetterAction.CONSTANT_VALUE + if variable.binding.getter_action + not in {ModuleGetterAction.CONSTANT_VALUE, ModuleGetterAction.NATIVE_CONSTANT_VALUE} for python_name in variable.binding.python_names ) if not entries: @@ -11688,24 +11693,17 @@ def _module_constant_nodes( nodes = [] index = 0 for variable in namespace.variables: - if variable.binding.getter_action is not ModuleGetterAction.CONSTANT_VALUE: + if variable.binding.getter_action not in { + ModuleGetterAction.CONSTANT_VALUE, + ModuleGetterAction.NATIVE_CONSTANT_VALUE, + }: continue - scalar_type = PrimitiveScalarTypeRegistry.type_for(variable.semantic_type_name) for python_name in variable.binding.python_names: value_name = f"constant_{variable.symbol_name}_value_{index}" object_name = f"constant_{variable.symbol_name}_object_{index}" nodes.extend( ( - CDeclaration( - value_name, - scalar_type.c_spelling, - CodeExpression(self._module_literal(variable, variable.binding.constant_value)), - ), - CDeclaration( - object_name, - "PyObject *", - CodeExpression(self._scalar_result_expression(scalar_type, f"&{value_name}", module=True)), - ), + *self._module_constant_declarations(variable, value_name, object_name), CExpressionStatement( CodeExpression(f"if ({object_name} == NULL) {{ Py_DECREF(mod); return NULL; }}") ), @@ -11720,6 +11718,37 @@ def _module_constant_nodes( index += 1 return tuple(nodes) + def _module_constant_declarations( + self, + variable: ModuleVariablePlan, + value_name: str, + object_name: str, + ) -> tuple[CDeclaration, ...]: + """Materialize one planned binding or native constant value.""" + if variable.datatype_family is DatatypeFamily.STRING: + literal = self._c_string_literal(str(variable.binding.constant_value)) + return ( + CDeclaration( + object_name, + "PyObject *", + CodeExpression(f"PyUnicode_FromString({literal})"), + ), + ) + scalar_type = PrimitiveScalarTypeRegistry.type_for(variable.semantic_type_name) + value_expression = ( + f"{self._module_bridge_getter_name(variable)}()" + if variable.binding.getter_action is ModuleGetterAction.NATIVE_CONSTANT_VALUE + else self._module_literal(variable, variable.binding.constant_value) + ) + return ( + CDeclaration(value_name, scalar_type.c_spelling, CodeExpression(value_expression)), + CDeclaration( + object_name, + "PyObject *", + CodeExpression(self._scalar_result_expression(scalar_type, f"&{value_name}", module=True)), + ), + ) + def _module_literal(self, plan: ModuleVariablePlan, value: object) -> str: """Dispatch one completed datatype family to its C literal spelling.""" family = plan.datatype_family diff --git a/prik/wrapper_codegen/docstrings.py b/prik/wrapper_codegen/docstrings.py index 9581ae7fb..cbaf2ebfb 100644 --- a/prik/wrapper_codegen/docstrings.py +++ b/prik/wrapper_codegen/docstrings.py @@ -263,7 +263,10 @@ def module_variable(self, variable: ModuleVariablePlan) -> str: nullable = variable.binding.getter_action is ModuleGetterAction.NULLABLE_SNAPSHOT lines = [f"{name} : {self._type(variable, nullable=nullable, signature=False)}"] lines.extend(self._array_lines(variable.array)) - if variable.binding.getter_action is ModuleGetterAction.CONSTANT_VALUE: + if variable.binding.getter_action in { + ModuleGetterAction.CONSTANT_VALUE, + ModuleGetterAction.NATIVE_CONSTANT_VALUE, + }: lines.append(" Read-only constant.") elif variable.binding.getter_action is ModuleGetterAction.BORROWED_ARRAY_VIEW: lines.append(" Native-owned borrowed view; mutations affect module storage.") diff --git a/prik/wrapper_codegen/fortran/bridge.py b/prik/wrapper_codegen/fortran/bridge.py index 66aa356ad..396ca31bd 100644 --- a/prik/wrapper_codegen/fortran/bridge.py +++ b/prik/wrapper_codegen/fortran/bridge.py @@ -1624,6 +1624,8 @@ def _lower_module_getter(self, plan: ModuleVariablePlan) -> tuple[FortranFunctio match action: case ModuleGetterAction.CONSTANT_VALUE: return self._lower_module_getter_constant_value(plan) + case ModuleGetterAction.NATIVE_CONSTANT_VALUE: + return self._lower_module_getter_direct_value(plan) case ModuleGetterAction.DIRECT_VALUE: return self._lower_module_getter_direct_value(plan) case ModuleGetterAction.NULLABLE_SNAPSHOT: diff --git a/prik/wrapper_codegen/generator.py b/prik/wrapper_codegen/generator.py index 13491a2b5..efad5b2eb 100644 --- a/prik/wrapper_codegen/generator.py +++ b/prik/wrapper_codegen/generator.py @@ -818,14 +818,9 @@ def _module_getter_diagnostics(self, plan: ModuleVariablePlan) -> tuple[WrapperP if action is ModuleGetterAction.BORROWED_ARRAY_VIEW: return self._module_borrowed_array_view_diagnostics(plan) if action is ModuleGetterAction.CONSTANT_VALUE: - diagnostics = [] - if plan.bridge.getter_role is not None: - diagnostics.append( - self._diagnostic(plan.owner_path, "constant-has-bridge-getter", plan.bridge.getter_role) - ) - if plan.binding.constant_value is None: - diagnostics.append(self._diagnostic(plan.owner_path, "missing-module-constant-value", plan.owner_path)) - return tuple(diagnostics) + return self._binding_constant_getter_diagnostics(plan) + if action is ModuleGetterAction.NATIVE_CONSTANT_VALUE: + return self._native_constant_getter_diagnostics(plan) if action is ModuleGetterAction.DERIVED_OBJECT: return self._derived_module_getter_role_diagnostics(plan) if plan.bridge.getter_role is None: @@ -837,6 +832,36 @@ def _module_getter_diagnostics(self, plan: ModuleVariablePlan) -> tuple[WrapperP return (self._diagnostic(plan.owner_path, "missing-module-descriptor-kind", action.value),) return () + def _binding_constant_getter_diagnostics( + self, + plan: ModuleVariablePlan, + ) -> tuple[WrapperPlanDiagnostic, ...]: + """Validate one binding-materialized module constant.""" + diagnostics = [] + if plan.bridge.getter_role is not None: + diagnostics.append(self._diagnostic(plan.owner_path, "constant-has-bridge-getter", plan.bridge.getter_role)) + if plan.binding.constant_value is None: + diagnostics.append(self._diagnostic(plan.owner_path, "missing-module-constant-value", plan.owner_path)) + return tuple(diagnostics) + + def _native_constant_getter_diagnostics( + self, + plan: ModuleVariablePlan, + ) -> tuple[WrapperPlanDiagnostic, ...]: + """Validate one compiler-evaluated module constant.""" + diagnostics = [] + if plan.bridge.getter_role is None: + diagnostics.append( + self._diagnostic( + plan.owner_path, + "missing-module-getter-role", + plan.binding.getter_action.value, + ) + ) + if plan.binding.constant_value is not None: + diagnostics.append(self._diagnostic(plan.owner_path, "native-constant-has-binding-value", plan.owner_path)) + return tuple(diagnostics) + def _module_borrowed_array_view_diagnostics( self, plan: ModuleVariablePlan, @@ -993,7 +1018,10 @@ def _module_nonwriting_action_diagnostics( "pointer", }: return (self._diagnostic(plan.owner_path, "rejected-module-setter-without-descriptor", action.value),) - if action is SetterAction.OMIT and plan.binding.getter_action is not ModuleGetterAction.CONSTANT_VALUE: + if action is SetterAction.OMIT and plan.binding.getter_action not in { + ModuleGetterAction.CONSTANT_VALUE, + ModuleGetterAction.NATIVE_CONSTANT_VALUE, + }: return (self._diagnostic(plan.owner_path, "omitted-nonconstant-module-setter", action.value),) return () @@ -1014,6 +1042,7 @@ def _function_diagnostics(self, plan: FunctionPlan) -> tuple[WrapperPlanDiagnost ), *self._duplicate_role_diagnostics(plan), *self._available_role_diagnostics(plan), + *self._binding_conversion_order_diagnostics(plan), *self._function_output_diagnostics(plan), *self._string_result_aggregation_diagnostics(plan), *self._status_error_diagnostics(plan), @@ -1034,6 +1063,58 @@ def _function_diagnostics(self, plan: FunctionPlan) -> tuple[WrapperPlanDiagnost diagnostics.extend(self._string_writeback_diagnostics(plan)) return tuple(diagnostics) + def _binding_conversion_order_diagnostics( + self, + plan: FunctionPlan, + ) -> tuple[WrapperPlanDiagnostic, ...]: + """Require complete dependency-safe binding conversion ownership.""" + order = plan.binding.argument_conversion_order + owners = tuple(argument.owner_path for argument in plan.arguments) + diagnostics = [] + if Counter(order) != Counter(owners): + diagnostics.append(self._diagnostic(plan.owner_path, "invalid-binding-conversion-order", order)) + return tuple(diagnostics) + + positions = {owner: position for position, owner in enumerate(order)} + role_owners = {argument.binding.handoff_role: argument.owner_path for argument in plan.arguments} + diagnostics.extend(self._late_binding_extent_conversion_diagnostics(plan, positions, role_owners)) + return tuple(diagnostics) + + def _late_binding_extent_conversion_diagnostics( + self, + plan: FunctionPlan, + positions: dict[str, int], + role_owners: dict[str, str], + ) -> tuple[WrapperPlanDiagnostic, ...]: + """Reject a planned array conversion scheduled before a used extent.""" + diagnostics = [] + for argument in plan.arguments: + for dependency in self._binding_extent_dependency_owners(argument, role_owners): + if dependency != argument.owner_path and positions[dependency] > positions[argument.owner_path]: + diagnostics.append( + self._diagnostic( + argument.owner_path, + "late-binding-extent-conversion", + dependency, + ) + ) + return tuple(diagnostics) + + @staticmethod + def _binding_extent_dependency_owners( + argument: ArgumentTransferPlan, + role_owners: dict[str, str], + ) -> tuple[str, ...]: + """Return planned owners referenced by one array's extent roles.""" + if argument.array is None: + return () + return tuple( + role_owners[role] + for axis_roles in argument.array.extent_reference_roles + for role in axis_roles + if role in role_owners + ) + def _optional_literal_combination_diagnostics( self, plan: FunctionPlan, diff --git a/prik/wrapper_codegen/plan.py b/prik/wrapper_codegen/plan.py index 3f0163b1c..a2878dcfc 100644 --- a/prik/wrapper_codegen/plan.py +++ b/prik/wrapper_codegen/plan.py @@ -478,6 +478,7 @@ class BindingFunctionPlan(StageRecord): docstring: str release_gil: bool status_error: BindingStatusErrorPlan | None + argument_conversion_order: tuple[str, ...] public: bool = True diff --git a/prik/wrapper_codegen/planner.py b/prik/wrapper_codegen/planner.py index 58d853b20..a45566144 100644 --- a/prik/wrapper_codegen/planner.py +++ b/prik/wrapper_codegen/planner.py @@ -8,6 +8,7 @@ from prik.semantics import models from prik.semantics.native_array_handles import NATIVE_ARRAY_POINTER_C_DESCRIPTOR_HEADER from prik.semantics.wrapper_policy import ( + ArgumentConversionPhase, ArgumentHandoffMode, ArrayHandoffPolicy, CallbackHandoffPolicy, @@ -943,6 +944,7 @@ def _function_plan( ), release_gil=policy.release_gil, status_error=status_error, + argument_conversion_order=self._binding_argument_conversion_order(arguments), public=public, ), bridge=BridgeFunctionPlan( @@ -964,6 +966,81 @@ def _function_plan( release_actions=tuple(self.visit(action) for action in policy.release_actions), ) + @staticmethod + def _binding_argument_conversion_order( + arguments: tuple[ArgumentTransferPlan, ...], + ) -> tuple[str, ...]: + """Plan a stable conversion order that satisfies array-extent dependencies.""" + role_owners = {argument.binding.handoff_role: argument.owner_path for argument in arguments} + dependencies = WrapperPlanner._binding_conversion_dependencies(arguments, role_owners) + ordered: list[str] = [] + converted: set[str] = set() + remaining = list(WrapperPlanner._ranked_binding_arguments(arguments)) + while remaining: + ready_index = WrapperPlanner._ready_binding_argument_index(remaining, dependencies, converted) + if ready_index is None: + owners = tuple(argument.owner_path for argument in remaining) + raise ValueError(f"Cyclic binding argument conversion dependencies: {owners!r}") + argument = remaining.pop(ready_index) + ordered.append(argument.owner_path) + converted.add(argument.owner_path) + return tuple(ordered) + + @staticmethod + def _binding_conversion_dependencies( + arguments: tuple[ArgumentTransferPlan, ...], + role_owners: dict[str, str], + ) -> dict[str, set[str]]: + """Map each planned argument to the argument conversions it requires.""" + return { + argument.owner_path: WrapperPlanner._binding_extent_dependency_owners(argument, role_owners) + for argument in arguments + } + + @staticmethod + def _ranked_binding_arguments( + arguments: tuple[ArgumentTransferPlan, ...], + ) -> tuple[ArgumentTransferPlan, ...]: + """Preserve the established phase and Python-position preference.""" + return tuple( + sorted( + arguments, + key=lambda argument: ( + argument.binding.conversion_phase is ArgumentConversionPhase.DEFERRED_REPLACEMENT, + argument.python_position, + ), + ) + ) + + @staticmethod + def _ready_binding_argument_index( + remaining: list[ArgumentTransferPlan], + dependencies: dict[str, set[str]], + converted: set[str], + ) -> int | None: + """Find the first preferred argument whose dependencies are converted.""" + return next( + (index for index, argument in enumerate(remaining) if dependencies[argument.owner_path] <= converted), + None, + ) + + @staticmethod + def _binding_extent_dependency_owners( + argument: ArgumentTransferPlan, + role_owners: dict[str, str], + ) -> set[str]: + """Resolve the planned arguments needed before one array conversion.""" + if argument.array is None: + return set() + owners = { + role_owners[role] + for axis_roles in argument.array.extent_reference_roles + for role in axis_roles + if role in role_owners + } + owners.discard(argument.owner_path) + return owners + def _native_slot_plans(self, policy: FunctionWrapperPolicy) -> tuple[NativeCallSlotPlan, ...]: """Project ordered native call slots with their completed symbolic roles.""" return tuple( diff --git a/pyproject.toml b/pyproject.toml index 578a9d776..2ecbd9633 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,7 +110,6 @@ extend-exclude = [ "tests/c/fixtures/pyi", "tests/fortran/*/end_to_end/fixtures", "tests/fortran/*/pipeline/fixtures", - "tests/fortran/building_shared_library/end_to_end/real_libraries/*/contracts", "tests/fortran/pyi_contracts/*/end_to_end/fixtures", "tests/fortran/semantic_pyi_format/pipeline/fixtures", "prik.egg-info", @@ -153,7 +152,6 @@ exclude = [ "tests/c/fixtures/pyi/", "tests/fortran/*/end_to_end/fixtures/", "tests/fortran/*/pipeline/fixtures/", - "tests/fortran/building_shared_library/end_to_end/real_libraries/*/contracts/", "tests/fortran/pyi_contracts/*/end_to_end/fixtures/", "tests/fortran/semantic_pyi_format/pipeline/fixtures/", "prik.egg-info/", diff --git a/tests/README.md b/tests/README.md index 1a03bb882..01b495028 100644 --- a/tests/README.md +++ b/tests/README.md @@ -71,8 +71,11 @@ python3 -m pytest -q tests/shared python3 -m pytest -q tests/architecture ``` -BLAS and LAPACK remain in the dedicated real-library job. LAPACK is not part -of the default local verification command. +The full-library BLAS/LAPACK integration nodes and the complete correctness +projects in `examples/blas/` and `examples/lapack/` remain in the dedicated +real-library job. The BLAS and LAPACK sources are owned by +`examples/blas/native/` and `examples/lapack/native/`; LAPACK is not part of +the default local verification command. ## Markers @@ -81,8 +84,8 @@ selection: - `fortran_end_to_end` selects every compiled, imported, and called Fortran feature test, and nothing else; -- `real_library` selects only the dedicated BLAS/LAPACK native-source - end-to-end tests; +- `real_library` selects only the dedicated BLAS correctness example and + BLAS/LAPACK native-source end-to-end integration tests; - `property`, `regression`, `benchmark`, and `slow` retain their ordinary meanings; and - `toolchain_smoke` selects only the bounded portable compiler-profile subset diff --git a/tests/architecture/fortran/test_ci_toolchain_lanes.py b/tests/architecture/fortran/test_ci_toolchain_lanes.py index 2a5da52b3..5c3977acc 100644 --- a/tests/architecture/fortran/test_ci_toolchain_lanes.py +++ b/tests/architecture/fortran/test_ci_toolchain_lanes.py @@ -20,18 +20,18 @@ def test_workflow_declares_pinned_ifx_and_flang_pairs_on_ubuntu_2404() -> None: text = WORKFLOW.read_text(encoding="utf-8") - assert text.startswith("name: Smoke Tests\n") + assert text.startswith("name: Compiler Compatibility\n") assert "runs-on: ubuntu-24.04" in text assert 'PRIK_IFX_VERSION: "2026.1.1"' in text assert 'PRIK_FLANG_VERSION: "22.1.8"' in text assert 'PRIK_FLANG_RUNTIME_VERSION: "22.1.7"' in text for snippet in ( "- toolchain: ifx", - "display_name: Linux · Intel IFX 2026.1.1 · Python 3.12", + "display_name: Ubuntu 24.04 · Intel IFX 2026.1.1 · Python 3.12", "fortran_compiler: ifx", "c_compiler: icx", "- toolchain: flang", - "display_name: Linux · LLVM Flang 22.1.8 · Python 3.12", + "display_name: Ubuntu 24.04 · LLVM Flang 22.1.8 · Python 3.12", "fortran_compiler: flang", "c_compiler: clang", ): @@ -70,7 +70,7 @@ def test_macos_flang_lane_installs_a_coherent_pair_and_runs_strict_smoke() -> No macos_job = text.split(" macos-flang-smoke:\n", maxsplit=1)[1] for snippet in ( - "name: macOS 15 ARM64 · LLVM Flang · Python 3.12", + "name: Compiler smoke · macOS 15 ARM64 · LLVM Flang · Python 3.12", "runs-on: macos-15", "brew install flang", 'flang_prefix="$(brew --prefix flang)"', @@ -97,7 +97,7 @@ def test_macos_lane_runs_strict_smoke_and_the_full_ordinary_suite() -> None: macos_job = text.split(" macos:\n", maxsplit=1)[1] for snippet in ( - "name: macOS 15 ARM64 · Python 3.12", + "name: Unit tests · macOS 15 ARM64 · Python 3.12", "runs-on: macos-15", "PRIK_GFORTRAN_BINARY: gfortran-13", "PRIK_GCC_BINARY: gcc-13", diff --git a/tests/architecture/fortran/test_language_ownership.py b/tests/architecture/fortran/test_language_ownership.py index 1d77de497..aeadb60db 100644 --- a/tests/architecture/fortran/test_language_ownership.py +++ b/tests/architecture/fortran/test_language_ownership.py @@ -13,7 +13,8 @@ FEATURE_ROOT = FORTRAN_ROOT FORTRAN_INDEX = FORTRAN_ROOT / "README.md" ROADMAP = REPO_ROOT / "docs/maintainer/roadmap/fortran-test-suite-cleanup-checklist.md" -REAL_LIBRARY_ROOT = FEATURE_ROOT / "building_shared_library" / "end_to_end" / "real_libraries" +BLAS_EXAMPLE_ROOT = REPO_ROOT / "examples" / "blas" +LAPACK_EXAMPLE_ROOT = REPO_ROOT / "examples" / "lapack" FEATURE_DOCS = { "data_types": "docs/user/guide/data-types.md", @@ -180,15 +181,11 @@ def test_fortran_index_names_every_infrastructure_owner() -> None: assert f"`{owner}`" in text -def test_real_library_owner_contains_only_full_blas_and_lapack_native_projects() -> None: - assert {path.name for path in REAL_LIBRARY_ROOT.glob("test_*.py")} == {"test_full_libraries.py"} - assert {path.name for path in REAL_LIBRARY_ROOT.iterdir() if path.is_dir() and path.name != "__pycache__"} == { - "blas", - "lapack", - } - for library in ("blas", "lapack"): - assert (REAL_LIBRARY_ROOT / library / "native").is_dir() - assert sorted(REAL_LIBRARY_ROOT.rglob("*.pyi")) == [] +def test_real_library_examples_have_single_native_source_owners() -> None: + assert (BLAS_EXAMPLE_ROOT / "native").is_dir() + assert (LAPACK_EXAMPLE_ROOT / "native").is_dir() + assert len(tuple((BLAS_EXAMPLE_ROOT / "native").iterdir())) == 155 + assert len(tuple((LAPACK_EXAMPLE_ROOT / "native").iterdir())) == 2062 def test_final_language_roots_do_not_cross_import_or_read_fixtures() -> None: diff --git a/tests/architecture/fortran/test_smoke_selection.py b/tests/architecture/fortran/test_smoke_selection.py index 70b86ce1b..e49cc73e2 100644 --- a/tests/architecture/fortran/test_smoke_selection.py +++ b/tests/architecture/fortran/test_smoke_selection.py @@ -27,7 +27,6 @@ "platforms", "profile", "profiles", - "real_libraries", } diff --git a/tests/fortran/CONTRACT_COVERAGE.md b/tests/fortran/CONTRACT_COVERAGE.md index f3a3e936c..706bcc0c4 100644 --- a/tests/fortran/CONTRACT_COVERAGE.md +++ b/tests/fortran/CONTRACT_COVERAGE.md @@ -191,7 +191,7 @@ Authoritative sources: | [Fortran Wrapper: Semantic Stub Output](../../docs/user/reference/fortran-wrapper.md#semantic-stub-output) | Supported | one flat combined package; one entry; native module leaves; no per-source or synthetic directory; entry-only semantic input | `tests/fortran/building_shared_library/end_to_end/test_multi_source_builds.py::test_multi_source_pyi_out_writes_one_flat_combined_package`
`tests/fortran/building_shared_library/pipeline/test_pyi_build_modes.py::test_generated_pyi_matches_checked_in_fixture` | `tests/fortran/building_shared_library/end_to_end/test_multi_source_builds.py::test_multi_source_generated_contract_build_matches_source_runtime_and_link_order` | — | canonical | | [Fortran Wrapper: Editable Makefile](../../docs/user/reference/fortran-wrapper.md#editable-makefile) | Supported | resolved compiler; Fortran and C wrapper flags; ordered source prerequisites; manifest-backed `.pyi` generation and replay | `tests/fortran/building_shared_library/pipeline/test_pyi_build_modes.py::test_pyi_makefile_manifest_and_replay_workflows` | `tests/fortran/building_shared_library/end_to_end/test_multi_source_builds.py::test_makefile_mode_reproduces_multi_source_build` | — | canonical | | [Fortran Wrapper: Advanced Multi-Source Integration](../../docs/user/reference/fortran-wrapper.md#advanced-multi-source-integration) | Partially supported | explicit caller-ordered sources, module directories, libraries, and runtime paths; no automatic dependency, prebuilt-module, or external-library discovery | `tests/fortran/building_shared_library/end_to_end/test_source_build_modes.py::test_source_build_reuses_native_plan_for_additional_compile_and_link_inputs` | `tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_required_transitive_named_library_resolves_runtime_symbol` | `tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_missing_module_directory_reports_compile_error` (`compiling`) | canonical | -| [Semantic `.pyi`: Native Artifacts And Link Resolution](../../docs/user/reference/semantic-pyi-format.md#native-artifacts-and-link-resolution) | Supported | no filename inference; objects, archives, direct and named shared libraries; transitive providers; archive groups; missing/duplicate/incompatible artifact diagnostics; full BLAS/LAPACK bundles | `tests/fortran/building_shared_library/pipeline/test_pyi_build_modes.py::test_pyi_cli_preserves_explicit_ordered_link_items`
`tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_static_archive_groups_resolve_cyclic_archive_dependencies` | `tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py::test_full_library_wrapper_imports_every_root_procedure_from_cached_shared_library[blas]`
`tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py::test_full_library_wrapper_imports_every_root_procedure_from_cached_shared_library[lapack]` | `tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_missing_symbol_reports_native_link_or_loader_error` (`import`)
`tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_duplicate_native_definitions_report_linker_error` (`compiling`) | real-library | +| [Semantic `.pyi`: Native Artifacts And Link Resolution](../../docs/user/reference/semantic-pyi-format.md#native-artifacts-and-link-resolution) | Supported | no filename inference; objects, archives, direct and named shared libraries; transitive providers; archive groups; missing/duplicate/incompatible artifact diagnostics | `tests/fortran/building_shared_library/pipeline/test_pyi_build_modes.py::test_pyi_cli_preserves_explicit_ordered_link_items`
`tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_static_archive_groups_resolve_cyclic_archive_dependencies` | `tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_mixed_module_external_bundle_resolves_all_native_input_kinds` | `tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_missing_symbol_reports_native_link_or_loader_error` (`import`)
`tests/fortran/building_shared_library/end_to_end/test_native_bundles.py::test_duplicate_native_definitions_report_linker_error` (`compiling`) | canonical | | [Semantic `.pyi`: Contract Imports](../../docs/user/reference/semantic-pyi-format.md#contract-imports) | Supported | explicit `prik.contracts` imports; arbitrary aliases; missing imports rejected; ordinary and relative imports preserved | `tests/fortran/semantic_pyi_format/semantics/test_imports_and_packages.py::test_convert_pyi_to_ir_requires_imported_contract_types`
`tests/fortran/semantic_pyi_format/semantics/test_types_and_values.py::test_convert_pyi_to_ir_follows_arbitrary_contract_aliases` | — | `tests/fortran/semantic_pyi_format/semantics/test_imports_and_packages.py::test_convert_pyi_to_ir_requires_imported_contract_types` (`semantics`) | canonical | | [Semantic `.pyi`: Misuse, Diagnostics And Risk](../../docs/user/reference/semantic-pyi-format.md#misuse-diagnostics-and-risk) | Supported | syntax, semantic shape, native contract, policy, and unsafe-boundary diagnostics; filename-aware failures; no silent fallback | `tests/fortran/semantic_pyi_format/semantics/test_imports_and_packages.py::test_pyi_file_to_semantic_module_and_modules_forward_module_name_encoding_and_filename` | — | `tests/fortran/semantic_pyi_format/parsing/test_python_ast_contracts.py::test_pyi_parser_reports_unsupported_lines_and_invalid_helpers` (`parsing`)
`tests/fortran/semantic_pyi_format/pipeline/test_contract_loading.py::test_pyi_python_api_rejects_invalid_projection_before_codegen` (`pipeline`) | canonical | | [Semantic `.pyi`: File Shape](../../docs/user/reference/semantic-pyi-format.md#file-shape) | Supported | Python AST boundary; imports, annotated declarations, classes, ellipsis-only functions, and supported decorators | `tests/fortran/semantic_pyi_format/parsing/test_python_ast_contracts.py::test_pyi_parser_returns_python_ast_only`
`tests/fortran/semantic_pyi_format/parsing/test_python_ast_contracts.py::test_convert_pyi_to_ir_accepts_parsed_pyi_ast_only` | — | `tests/fortran/semantic_pyi_format/parsing/test_python_ast_contracts.py::test_pyi_parser_reports_unsupported_lines_and_invalid_helpers` (`parsing`) | canonical | diff --git a/tests/fortran/README.md b/tests/fortran/README.md index 5d8ede9e3..e113c5250 100644 --- a/tests/fortran/README.md +++ b/tests/fortran/README.md @@ -95,7 +95,8 @@ artifact-consumer, and support-consumer inventories live under - Every pytest node below a feature `end_to_end/` carries `fortran_end_to_end`, and no other node does. -- Only BLAS/LAPACK native-source end-to-end nodes additionally carry +- Only the complete `examples/blas/` and `examples/lapack/` correctness + projects and BLAS/LAPACK native-source integration nodes additionally carry `real_library`. - `toolchain_smoke` will select exact portable rows from the completed ordinary end-to-end suite; it is not a separate directory. @@ -106,6 +107,6 @@ Run all migrated Fortran evidence with: python3 -m pytest -q tests/fortran ``` -Until the real-library migration is complete, use the legacy exclusions -documented in the repository-level test map and never run LAPACK locally -without an explicit request. +Run the BLAS project by sourcing `examples/blas/build_all.sh`, then running +`python3 -m pytest -q examples/blas/tests`. Never run LAPACK locally without an +explicit request. diff --git a/tests/fortran/arrays/wrapper_codegen/test_dense_array_shape_lowering.py b/tests/fortran/arrays/wrapper_codegen/test_dense_array_shape_lowering.py index 8c3d3ac61..a66ca3e16 100644 --- a/tests/fortran/arrays/wrapper_codegen/test_dense_array_shape_lowering.py +++ b/tests/fortran/arrays/wrapper_codegen/test_dense_array_shape_lowering.py @@ -181,9 +181,19 @@ def test_dense_array_lowering_uses_planned_shape_checks_and_bridge_orientation() def test_external_interface_declares_late_extent_before_dependent_array(): - artifacts = WrapperCodeGenerator().generate(_late_extent_external_plan()) + plan = _late_extent_external_plan() + function = plan.namespaces[0].functions[0] + artifacts = WrapperCodeGenerator().generate(plan) + c_source = next(source.text for source in artifacts.sources if source.path.suffix == ".c") bridge_source = next(source.text for source in artifacts.sources if source.path.suffix == ".f90") + assert function.binding.argument_conversion_order == ( + "late_extent_external.late_extent.n", + "late_extent_external.late_extent.values", + ) + assert c_source.index("prik_int32_unpack_exact(bound_n_obj, &bound_n)") < c_source.index( + "Argument values has incompatible shape at axis 0" + ) signature = "subroutine late_extent(values, n)" interface = bridge_source.split(signature, maxsplit=1)[1].split("end subroutine late_extent", maxsplit=1)[0] assert interface.index("integer(c_int32_t), optional :: n") < interface.index( @@ -191,6 +201,15 @@ def test_external_interface_declares_late_extent_before_dependent_array(): ) +def test_edited_binding_conversion_order_cannot_read_an_extent_late(): + plan = _late_extent_external_plan() + function = plan.namespaces[0].functions[0] + function.binding.argument_conversion_order = tuple(reversed(function.binding.argument_conversion_order)) + + with pytest.raises(ValueError, match="late-binding-extent-conversion"): + WrapperCodeGenerator().generate(plan) + + def test_unavailable_dense_extent_role_fails_before_backend_lowering(): plan = _dense_plan() array = plan.namespaces[0].functions[0].arguments[-1].array diff --git a/tests/fortran/building_shared_library/README.md b/tests/fortran/building_shared_library/README.md index 8a5746211..8319d9992 100644 --- a/tests/fortran/building_shared_library/README.md +++ b/tests/fortran/building_shared_library/README.md @@ -12,19 +12,15 @@ Evidence is split by the stage that establishes it: - `pipeline/` checks generated contracts, manifests, Makefiles, explicit native inputs, and source-free `.pyi` build transitions; and - `end_to_end/` compiles and imports source, multi-source, runtime-compatibility, - mixed-native-bundle, and real-library extensions. + and mixed-native-bundle extensions. -Run the feature without the dedicated full-library test with: +Run the complete feature with: ```bash -python3 -m pytest -q tests/fortran/building_shared_library \ - --ignore=tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py +python3 -m pytest -q tests/fortran/building_shared_library ``` -Run the full BLAS node locally only when real-library verification is needed. -The full LAPACK node is intentionally left to its dedicated GitHub Actions job. -Each node generates its intermediate semantic `.pyi` package from the native -library sources inside its pytest temporary directory. BLAS and LAPACK keep no -checked generated contract, edited contract, or source-free replay fixture; -their only evidence is the full native-source build, wrapper compilation and -link, extension import, public-surface audit, and representative runtime call. +Full BLAS and LAPACK corpus coverage lives in `examples/blas/` and +`examples/lapack/`. Their dedicated GitHub Actions lane executes the documented +build scripts, user-facing correctness tests, and maintainer-only full-surface +audits without rebuilding a second wrapper. diff --git a/tests/fortran/building_shared_library/compiling/test_example_native_library.py b/tests/fortran/building_shared_library/compiling/test_example_native_library.py new file mode 100644 index 000000000..585746869 --- /dev/null +++ b/tests/fortran/building_shared_library/compiling/test_example_native_library.py @@ -0,0 +1,104 @@ +"""Focused checks for the copyable example native-library builder.""" + +from __future__ import annotations + +import os +from pathlib import Path + +import pytest + +from examples import native_library + + +@pytest.mark.parametrize("example", ("blas", "lapack")) +def test_aggregate_example_build_restores_the_workspace(example: str) -> None: + script = (native_library.EXAMPLES_ROOT / example / "build_all.sh").read_text(encoding="utf-8") + lines = script.splitlines() + + f2py_build = next(index for index, line in enumerate(lines) if "build_f2py.sh" in line) + restore_workspace = lines.index('cd "$EXAMPLE_WORKSPACE"') + python_path_export = next(index for index, line in enumerate(lines) if line.startswith("export PYTHONPATH=")) + assert f2py_build < restore_workspace < python_path_export + + +def test_native_cache_preserves_module_files_for_wrapper_compilation(tmp_path: Path, monkeypatch) -> None: + sources = ( + native_library.LAPACK_SOURCE_ROOT / "la_constants.f90", + native_library.LAPACK_SOURCE_ROOT / "la_xisnan.F90", + native_library.LAPACK_SOURCE_ROOT / "dlamch.f", + ) + + def compile_source(_compiler: str, source: Path, native_object: Path, module_dir: Path) -> None: + native_object.parent.mkdir(parents=True, exist_ok=True) + native_object.touch() + if source.stem.lower() in native_library.NATIVE_MODULE_SOURCE_STEMS: + (module_dir / f"{source.stem.lower()}.mod").touch() + + def compile_independent_sources( + compiler: str, + selected_sources: tuple[Path, ...], + objects_dir: Path, + module_dir: Path, + _jobs: int, + ) -> None: + for source in selected_sources: + compile_source( + compiler, + source, + native_library._cached_object_path(objects_dir, source), + module_dir, + ) + + monkeypatch.setattr(native_library, "_compile_source", compile_source) + monkeypatch.setattr(native_library, "_compile_independent_sources", compile_independent_sources) + + cache_dir = tmp_path / "native" + objects = native_library._cached_objects(cache_dir, sources, "gfortran", 2) + + assert all(path.is_file() for path in objects) + assert (cache_dir / "modules" / "la_constants.mod").is_file() + assert (cache_dir / "modules" / "la_xisnan.mod").is_file() + + def fail_if_recompiled(*_args) -> None: + raise AssertionError("warm cache recompiled a module") + + monkeypatch.setattr(native_library, "_compile_source", fail_if_recompiled) + assert native_library._cached_objects(cache_dir, sources, "gfortran", 2) == objects + + +@pytest.mark.parametrize( + ("library", "expected_dependencies"), + (("blas", ()), ("lapack", ("-llapack", "-lblas"))), +) +def test_shared_example_library_links_its_native_dependencies( + tmp_path: Path, + monkeypatch, + library: str, + expected_dependencies: tuple[str, ...], +) -> None: + commands = [] + + def run(command: tuple[str, ...], *, check: bool) -> None: + assert check is True + commands.append(command) + Path(command[3]).touch() + + monkeypatch.setattr(native_library.subprocess, "run", run) + archive = tmp_path / f"libprik_full_{library}.a" + archive.touch() + + shared_library = native_library._cached_shared_library(tmp_path, library, archive, "gfortran") + + assert shared_library.is_file() + assert commands == [ + ( + "gfortran", + "-shared", + "-o", + str(tmp_path / f"{shared_library.name}.{os.getpid()}.tmp"), + "-Wl,--whole-archive", + str(archive), + "-Wl,--no-whole-archive", + *expected_dependencies, + ) + ] diff --git a/tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py b/tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py deleted file mode 100644 index 890fea1a6..000000000 --- a/tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py +++ /dev/null @@ -1,423 +0,0 @@ -"""Real BLAS/LAPACK full-contract wrapper import and runtime tests.""" - -from __future__ import annotations - -import concurrent.futures -import hashlib -import importlib -import os -import shutil -import subprocess -import sys -import sysconfig -from pathlib import Path - -import numpy as np -import pytest - -from tests.fortran._support.wrapper_build import REPO_ROOT -from prik import build_pyi_extension -from prik.pipeline.pyi import pyi_paths_to_semantic_modules - -FORTRAN_LIBRARY_ROOT = Path(__file__).parent -NATIVE_CACHE_ENV = "PRIK_REAL_LIBRARY_NATIVE_CACHE_DIR" -NATIVE_JOBS_ENV = "PRIK_REAL_LIBRARY_NATIVE_JOBS" -DEFAULT_NATIVE_CACHE_ROOT = REPO_ROOT / ".pytest_cache" / "prik" / "real-library-native" -NATIVE_CACHE_VERSION = "full-library-v3" -NATIVE_MODULE_SOURCE_STEMS = {"la_constants", "la_xisnan"} -DEFAULT_NATIVE_COMPILE_JOB_LIMIT = 8 -pytestmark = pytest.mark.fortran_end_to_end -FULL_LIBRARY_WRAPPER_FLAGS = ("-O0", "-g0") -FORTRAN_SUFFIXES = {".f", ".f90", ".f95", ".f03", ".f08", ".for", ".f77", ".ftn"} -FULL_LIBRARY_CASES = { - "blas": { - "root_function_count": 155, - "source_stem_exceptions": set(), - "extra_function_names": set(), - "sentinel_functions": {"dasum", "daxpy", "ddot", "dgemm", "dscal", "lsame", "xerbla"}, - }, - "lapack": { - "root_function_count": 2063, - "source_stem_exceptions": {"la_constants", "la_xisnan"}, - "extra_function_names": {"dladiv1", "dladiv2", "sladiv1", "sladiv2"}, - "sentinel_functions": {"dgesv", "dgetrf", "dgetrs", "dlamrg", "zgesv"}, - }, -} -LAPACK_RUNTIME_EXCLUDED_IMPORTS = {"from . import LA_CONSTANTS\n", "from . import LA_XISNAN\n"} - - -def _compiler() -> str: - compiler = shutil.which("gfortran") - if compiler is None: - pytest.skip("gfortran is required for real BLAS/LAPACK wrapper tests") - return compiler - - -def _archiver() -> str: - archiver = shutil.which("ar") - if archiver is None: - pytest.skip("ar is required for real BLAS/LAPACK native cache tests") - return archiver - - -def _library_sources(library: str) -> tuple[Path, ...]: - root = FORTRAN_LIBRARY_ROOT / library / "native" - return tuple(sorted(path for path in root.iterdir() if path.is_file() and path.suffix.lower() in FORTRAN_SUFFIXES)) - - -def _native_sources(library: str) -> tuple[Path, ...]: - if library == "blas": - return _library_sources("blas") - lapack_sources = _library_sources("lapack") - module_sources = tuple( - source - for source in ( - FORTRAN_LIBRARY_ROOT / "lapack" / "native" / "la_constants.f90", - FORTRAN_LIBRARY_ROOT / "lapack" / "native" / "la_xisnan.F90", - ) - if source.is_file() - ) - module_source_set = set(module_sources) - lapack_rest = tuple(source for source in lapack_sources if source not in module_source_set) - lapack_stems = {source.stem.lower() for source in lapack_sources} - blas_dependencies = tuple(source for source in _library_sources("blas") if source.stem.lower() not in lapack_stems) - return (*module_sources, *lapack_rest, *blas_dependencies) - - -def _source_stems(library: str) -> set[str]: - return {path.stem.lower() for path in _library_sources(library)} - - -def _compiler_identity(compiler: str) -> str: - result = subprocess.run([compiler, "--version"], capture_output=True, text=True, check=False) - first_line = result.stdout.splitlines()[0] if result.stdout else compiler - return f"{Path(compiler).resolve()}:{first_line}" - - -def _native_platform_identity() -> str: - return f"{sysconfig.get_platform()}:{os.name}:{sys.maxsize}" - - -def _source_digest(source: Path) -> str: - digest = hashlib.sha256() - with source.open("rb") as stream: - for chunk in iter(lambda: stream.read(1024 * 1024), b""): - digest.update(chunk) - return digest.hexdigest() - - -def _native_cache_key(library: str, compiler: str, sources: tuple[Path, ...]) -> str: - digest = hashlib.sha256() - digest.update(NATIVE_CACHE_VERSION.encode()) - digest.update(b"\0") - digest.update(library.encode()) - digest.update(b"\0") - digest.update(_compiler_identity(compiler).encode()) - digest.update(b"\0") - digest.update(_native_platform_identity().encode()) - for source in sources: - digest.update(b"\0") - digest.update(source.relative_to(REPO_ROOT).as_posix().encode()) - digest.update(b":") - digest.update(_source_digest(source).encode()) - return digest.hexdigest()[:24] - - -def _native_cache_root() -> Path: - configured = os.environ.get(NATIVE_CACHE_ENV) - if configured: - return Path(configured).expanduser() - return DEFAULT_NATIVE_CACHE_ROOT - - -def _native_compile_jobs() -> int: - configured = os.environ.get(NATIVE_JOBS_ENV) - if configured: - try: - jobs = int(configured) - except ValueError: - pytest.fail(f"{NATIVE_JOBS_ENV} must be a positive integer, got {configured!r}") - if jobs < 1: - pytest.fail(f"{NATIVE_JOBS_ENV} must be a positive integer, got {configured!r}") - return jobs - return max(1, min(os.cpu_count() or 1, DEFAULT_NATIVE_COMPILE_JOB_LIMIT)) - - -def _generate_contract(source_root: Path, package: Path) -> Path: - subprocess.run( - [ - sys.executable, - "-m", - "prik", - "generate", - "--pyi", - str(source_root), - "--language", - "fortran", - "--out", - str(package), - ], - capture_output=True, - text=True, - check=True, - ) - return package / "__init__.pyi" - - -def _contract_modules(package: Path): - return pyi_paths_to_semantic_modules([package]) - - -def _root_module(package: Path): - return next(module for module in _contract_modules(package) if module.name == "__init__") - - -def _function_names(package: Path) -> set[str]: - return {function.name for module in _contract_modules(package) for function in module.functions} - - -def _cached_object_path(objects_dir: Path, source: Path) -> Path: - return objects_dir / source.relative_to(FORTRAN_LIBRARY_ROOT).with_suffix(".o") - - -def _compile_native_source(compiler: str, source: Path, native_object: Path, module_dir: Path) -> None: - native_object.parent.mkdir(parents=True, exist_ok=True) - subprocess.run( - [ - compiler, - "-fPIC", - "-c", - str(source), - "-o", - str(native_object), - "-J", - str(module_dir), - "-I", - str(module_dir), - ], - check=True, - ) - - -def _compile_independent_native_sources( - compiler: str, - sources: tuple[Path, ...], - objects_dir: Path, - module_dir: Path, -) -> None: - if not sources: - return - jobs = min(_native_compile_jobs(), len(sources)) - if jobs == 1: - for source in sources: - _compile_native_source(compiler, source, _cached_object_path(objects_dir, source), module_dir) - return - with concurrent.futures.ThreadPoolExecutor(max_workers=jobs) as executor: - futures = [ - executor.submit( - _compile_native_source, - compiler, - source, - _cached_object_path(objects_dir, source), - module_dir, - ) - for source in sources - ] - for future in concurrent.futures.as_completed(futures): - future.result() - - -def _split_ordered_module_sources(sources: tuple[Path, ...]) -> tuple[tuple[Path, ...], tuple[Path, ...]]: - module_sources = tuple(source for source in sources if source.stem.lower() in NATIVE_MODULE_SOURCE_STEMS) - module_source_set = set(module_sources) - independent_sources = tuple(source for source in sources if source not in module_source_set) - return module_sources, independent_sources - - -def _cached_objects(cache_dir: Path, sources: tuple[Path, ...], compiler: str) -> tuple[Path, ...]: - objects_dir = cache_dir / "objects" - complete = cache_dir / "objects.complete" - objects = tuple(_cached_object_path(objects_dir, source) for source in sources) - if complete.is_file() and all(obj.is_file() for obj in objects): - return objects - - temp_objects_dir = cache_dir / f"objects.{os.getpid()}.tmp" - temp_module_dir = cache_dir / f"modules.{os.getpid()}.tmp" - shutil.rmtree(temp_objects_dir, ignore_errors=True) - shutil.rmtree(temp_module_dir, ignore_errors=True) - temp_objects_dir.mkdir(parents=True) - temp_module_dir.mkdir(parents=True) - module_sources, independent_sources = _split_ordered_module_sources(sources) - for source in module_sources: - _compile_native_source(compiler, source, _cached_object_path(temp_objects_dir, source), temp_module_dir) - _compile_independent_native_sources(compiler, independent_sources, temp_objects_dir, temp_module_dir) - shutil.rmtree(objects_dir, ignore_errors=True) - temp_objects_dir.rename(objects_dir) - shutil.rmtree(temp_module_dir, ignore_errors=True) - complete.write_text(f"{NATIVE_CACHE_VERSION}\n", encoding="utf-8") - (cache_dir / "archive.complete").unlink(missing_ok=True) - (cache_dir / "shared.complete").unlink(missing_ok=True) - return tuple(_cached_object_path(objects_dir, source) for source in sources) - - -def _cached_archive(cache_dir: Path, library: str, objects: tuple[Path, ...]) -> Path: - archive = cache_dir / f"libprik_full_{library}.a" - complete = cache_dir / "archive.complete" - if complete.is_file() and archive.is_file(): - return archive - - temp_archive = cache_dir / f"{archive.name}.{os.getpid()}.tmp" - temp_archive.unlink(missing_ok=True) - subprocess.run([_archiver(), "rcs", str(temp_archive), *(str(obj) for obj in objects)], check=True) - os.replace(temp_archive, archive) - complete.write_text(f"{NATIVE_CACHE_VERSION}\n", encoding="utf-8") - return archive - - -def _cached_shared_library(cache_dir: Path, library: str, archive: Path, compiler: str) -> Path: - shared = cache_dir / f"libprik_full_{library}.so" - complete = cache_dir / "shared.complete" - if complete.is_file() and shared.is_file(): - return shared - - temp_shared = cache_dir / f"{shared.name}.{os.getpid()}.tmp" - temp_shared.unlink(missing_ok=True) - subprocess.run( - [ - compiler, - "-shared", - "-o", - str(temp_shared), - "-Wl,--whole-archive", - str(archive), - "-Wl,--no-whole-archive", - ], - capture_output=True, - text=True, - check=True, - ) - os.replace(temp_shared, shared) - complete.write_text(f"{NATIVE_CACHE_VERSION}\n", encoding="utf-8") - return shared - - -def _cached_native_shared_library(library: str) -> Path: - compiler = _compiler() - sources = _native_sources(library) - cache_dir = _native_cache_root() / f"{library}-{_native_cache_key(library, compiler, sources)}" - cache_dir.mkdir(parents=True, exist_ok=True) - shared = cache_dir / f"libprik_full_{library}.so" - if (cache_dir / "shared.complete").is_file() and shared.is_file(): - return shared - objects = _cached_objects(cache_dir, sources, compiler) - archive = _cached_archive(cache_dir, library, objects) - return _cached_shared_library(cache_dir, library, archive, compiler) - - -def _runtime_entry(library: str, entry: Path, workdir: Path) -> Path: - if library != "lapack": - return entry - # The full LAPACK package also contains helper modules with constants and - # generic interfaces. Runtime evidence here covers the root procedure set. - runtime_package = workdir / "runtime_contract" / library - shutil.copytree(entry.parent, runtime_package) - runtime_entry = runtime_package / "__init__.pyi" - lines = runtime_entry.read_text(encoding="utf-8").splitlines(keepends=True) - runtime_entry.write_text( - "".join(line for line in lines if line not in LAPACK_RUNTIME_EXCLUDED_IMPORTS), - encoding="utf-8", - ) - return runtime_entry - - -def _import_extension(module_name: str, build_dir: Path, *, lazy: bool = False): - sys.modules.pop(module_name, None) - sys.path.insert(0, str(build_dir)) - old_flags = sys.getdlopenflags() - if lazy: - sys.setdlopenflags(getattr(os, "RTLD_LAZY", old_flags) | getattr(os, "RTLD_GLOBAL", 0)) - try: - return importlib.import_module(module_name) - finally: - if lazy: - sys.setdlopenflags(old_flags) - sys.path.remove(str(build_dir)) - - -def _assert_blas_runtime_smoke(module) -> None: - x = np.array([1.0, 2.0, 3.0], dtype=np.float64) - y = np.array([10.0, 20.0, 30.0], dtype=np.float64) - daxpy_scalars = module.daxpy(np.int32(3), np.float64(2.0), x, np.int32(1), y, np.int32(1)) - assert daxpy_scalars == (np.int32(3), np.float64(2.0), np.int32(1), np.int32(1)) - np.testing.assert_allclose(y, [12.0, 24.0, 36.0]) - assert module.ddot(np.int32(3), x, np.int32(1), y, np.int32(1)) == ( - np.float64(168.0), - np.int32(3), - np.int32(1), - np.int32(1), - ) - assert module.dasum(np.int32(3), y, np.int32(1)) == ( - np.float64(72.0), - np.int32(3), - np.int32(1), - ) - dscal_scalars = module.dscal(np.int32(3), np.float64(0.5), y, np.int32(1)) - assert dscal_scalars == (np.int32(3), np.float64(0.5), np.int32(1)) - np.testing.assert_allclose(y, [6.0, 12.0, 18.0]) - - -def _assert_lapack_runtime_smoke(module) -> None: - index = np.zeros(5, dtype=np.int32) - values = np.array([1.0, 4.0, 7.0, 2.0, 8.0], dtype=np.float64) - scalars = module.dlamrg(np.int32(3), np.int32(2), values, np.int32(1), np.int32(1), index) - assert scalars == (np.int32(3), np.int32(2), np.int32(1), np.int32(1)) - np.testing.assert_array_equal(index, [1, 4, 2, 3, 5]) - - -@pytest.mark.real_library -@pytest.mark.parametrize("library", ["blas", "lapack"]) -def test_full_library_wrapper_imports_every_root_procedure_from_cached_shared_library(library: str, tmp_path: Path): - entry = _generate_contract(FORTRAN_LIBRARY_ROOT / library / "native", tmp_path / "contracts" / library) - - root = _root_module(entry.parent) - all_function_names = _function_names(entry.parent) - case = FULL_LIBRARY_CASES[library] - - assert len(root.functions) == case["root_function_count"] - assert case["sentinel_functions"] <= all_function_names - assert _source_stems(library) - all_function_names == case["source_stem_exceptions"] - assert all_function_names - _source_stems(library) == case["extra_function_names"] - - shared = _cached_native_shared_library(library) - runtime_entry = _runtime_entry(library, entry, tmp_path) - expected_root_names = {function.name for function in _root_module(runtime_entry.parent).functions} - result = build_pyi_extension( - runtime_entry, - output_name=f"full_{library}", - output_dir=tmp_path / "build" / library, - native_objects=[shared], - wrapper_fortran_flags=FULL_LIBRARY_WRAPPER_FLAGS, - wrapper_c_flags=FULL_LIBRARY_WRAPPER_FLAGS, - ) - module = _import_extension(result.module_name, result.output_dir, lazy=library == "lapack") - - missing = sorted(name for name in expected_root_names if not hasattr(module, name)) - assert missing == [] - native_plan = result.native_build_plan.to_dict() - assert native_plan["link_items"] == [{"kind": "shared_library", "path": str(shared)}] - assert native_plan["compilation_units"] == [] - assert native_plan["module_dirs"] == [] - assert result.manifest is not None - assert result.manifest["compiler"]["wrapper_fortran_flags"] == list(FULL_LIBRARY_WRAPPER_FLAGS) - assert result.manifest["compiler"]["wrapper_c_flags"] == list(FULL_LIBRARY_WRAPPER_FLAGS) - - if library == "blas": - bridge = (result.output_dir / "bind_c_full_blas_wrapper.f90").read_text(encoding="utf-8").lower() - assert "use full_blas_interfaces" not in bridge - assert "external :: daxpy" in bridge - assert "subroutine daxpy(" not in bridge - assert "private\n" not in bridge - assert "public :: bind_c_daxpy" not in bridge - _assert_blas_runtime_smoke(module) - else: - _assert_lapack_runtime_smoke(module) diff --git a/tests/fortran/building_shared_library/end_to_end/test_source_build_modes.py b/tests/fortran/building_shared_library/end_to_end/test_source_build_modes.py index f39ebdb58..fa96b35de 100644 --- a/tests/fortran/building_shared_library/end_to_end/test_source_build_modes.py +++ b/tests/fortran/building_shared_library/end_to_end/test_source_build_modes.py @@ -392,6 +392,111 @@ def test_source_build_reuses_native_plan_for_additional_compile_and_link_inputs( ) +def test_source_directory_can_plan_a_wrapper_without_compiling_input_sources(tmp_path: Path): + source_dir = tmp_path / "native" + nested_dir = source_dir / "nested" + output_dir = tmp_path / "generated" + native_library = tmp_path / "libnative.so" + source_dir.mkdir() + nested_dir.mkdir() + shutil.copyfile(VERBOSE_SOURCE, source_dir / VERBOSE_SOURCE.name) + shutil.copyfile(SCALE_SOURCE, nested_dir / SCALE_SOURCE.name) + native_library.write_bytes(b"prebuilt native library fixture") + + result = build_fortran_extension( + source_dir, + output_name="prebuilt_sources", + output_dir=output_dir, + compile_input_sources=False, + native_objects=[native_library], + generate_sources=True, + ) + + plan = result.native_build_plan + assert result.sources == (nested_dir / SCALE_SOURCE.name, source_dir / VERBOSE_SOURCE.name) + assert plan.compilation_units == () + assert plan.produced_objects == () + assert [artifact.path for artifact in plan.prebuilt_artifacts] == [native_library] + assert plan.module_dirs == () + assert plan.link_items == (NativeLinkItem("shared_library", native_library),) + + +def test_source_build_still_compiles_explicit_hidden_sources_when_input_compilation_is_disabled(tmp_path: Path): + source = tmp_path / SCALAR_SOURCE.name + support = tmp_path / VERBOSE_SOURCE.name + native_library = tmp_path / "libnative.so" + shutil.copyfile(SCALAR_SOURCE, source) + shutil.copyfile(VERBOSE_SOURCE, support) + native_library.write_bytes(b"prebuilt native library fixture") + + result = build_fortran_extension( + source, + output_dir=tmp_path / "generated", + compile_input_sources=False, + native_fortran_sources=[support], + native_objects=[native_library], + generate_sources=True, + ) + + plan = result.native_build_plan + assert [unit.source for unit in plan.compilation_units] == [support] + assert source not in [unit.source for unit in plan.compilation_units] + + +def test_cli_builds_from_a_source_directory_and_prebuilt_object_only(tmp_path: Path): + source_dir = tmp_path / "native" + native_dir = tmp_path / "prebuilt" + output_dir = tmp_path / "wrapper" + source_dir.mkdir() + native_dir.mkdir() + source = source_dir / SCALE_SOURCE.name + native_object = native_dir / "scale.o" + shutil.copyfile(SCALE_SOURCE, source) + subprocess.run( + ["gfortran", "-c", "-fPIC", str(source), "-o", str(native_object)], + check=True, + capture_output=True, + text=True, + ) + + completed = subprocess.run( + [ + sys.executable, + "-m", + "prik", + str(source_dir), + "--no-compile-input-sources", + "--native-objects", + str(native_object), + "--out", + "prebuilt_scale", + "--out-dir", + str(output_dir), + "--json", + ], + check=True, + capture_output=True, + text=True, + cwd=tmp_path, + ) + payload = json.loads(completed.stdout) + plan = payload["native_build_plan"] + + assert payload["sources"] == [str(source)] + assert plan["compilation_units"] == [] + assert plan["produced_objects"] == [] + assert plan["prebuilt_artifacts"] == [{"kind": "object", "path": str(native_object)}] + assert not (output_dir / "scale.o").exists() + + sys.modules.pop("prebuilt_scale", None) + sys.path.insert(0, str(tmp_path)) + try: + module = importlib.import_module("prebuilt_scale") + finally: + sys.path.remove(str(tmp_path)) + assert module.scale(np.float64(3.0), np.float64(2.5)) == np.float64(7.5) + + def test_native_link_plan_serializes_interleaved_item_kinds(): plan = NativeBuildPlan( link_items=( diff --git a/tests/fortran/command_line_interface/pipeline/_support.py b/tests/fortran/command_line_interface/pipeline/_support.py index 96e9860fb..e2a1e959a 100644 --- a/tests/fortran/command_line_interface/pipeline/_support.py +++ b/tests/fortran/command_line_interface/pipeline/_support.py @@ -57,6 +57,7 @@ def _main_args(**overrides): "makefile": False, "generate_sources": False, "build_manifest": None, + "no_compile_input_sources": False, "native_fortran_sources": None, "native_compile_flags": None, "native_objects": None, diff --git a/tests/fortran/command_line_interface/pipeline/test_argument_contract.py b/tests/fortran/command_line_interface/pipeline/test_argument_contract.py index ae03f81ed..21c71c2a6 100644 --- a/tests/fortran/command_line_interface/pipeline/test_argument_contract.py +++ b/tests/fortran/command_line_interface/pipeline/test_argument_contract.py @@ -148,6 +148,19 @@ class extra(Opaque): "A wrapper build expects recognized Fortran source suffixes or one semantic .pyi contract; " "unsupported input: input.unknown", ), + ( + {"no_compile_input_sources": True}, + "--no-compile-input-sources requires --native-fortran-sources, --native-objects, " + "--native-library, or --native-link-item", + ), + ( + { + "paths": ["input.pyi"], + "no_compile_input_sources": True, + "native_objects": ["implementation.o"], + }, + "--no-compile-input-sources applies only to source-driven wrapper builds", + ), ], ) def test_prik_main_preserves_validation_diagnostics(monkeypatch, overrides, expected): @@ -284,6 +297,28 @@ def test_cli_native_compile_flags_split_grouped_shell_words(): ) +def test_source_build_routes_disabled_input_compilation_to_the_pipeline(monkeypatch): + from prik.pipeline import build as pipeline_build + + calls = [] + result = types.SimpleNamespace(compiled=False) + monkeypatch.setattr( + pipeline_build, + "build_fortran_extension", + lambda *args, **kwargs: calls.append((args, kwargs)) or result, + ) + args = _main_args( + paths=["native"], + no_compile_input_sources=True, + native_objects=["libnative.so"], + ) + + assert prik_cli._run_wrap_build(args, types.SimpleNamespace(compiler="gfortran")) is result + assert calls[0][0] == (["native"],) + assert calls[0][1]["compile_input_sources"] is False + assert calls[0][1]["native_objects"] == ["libnative.so"] + + @pytest.mark.parametrize("jobs", ("0", "many")) def test_cli_compile_jobs_rejects_non_positive_or_non_integer_values(jobs: str, capsys) -> None: with pytest.raises(SystemExit) as exc_info: @@ -520,7 +555,10 @@ def assert_group_order(help_text, *headings): assert "Add a compiler include search directory" in build_help assert "default: gfortran" in normalized_build_help assert "default: ./__prik__" in normalized_build_help - assert "Fortran source file(s), or exactly one semantic .pyi contract" in normalized_build_help + assert ( + "Fortran source file(s), one source directory, or exactly one semantic .pyi contract" in normalized_build_help + ) + assert "--no-compile-input-sources" in build_help assert "Input language (default: fortran)" in normalized_build_help assert "Rebuild the extension from an existing prik-build.json" in normalized_build_help assert "Name the Python extension and stable NAME.so library" in normalized_build_help diff --git a/tests/fortran/conftest.py b/tests/fortran/conftest.py index 580a0dfa9..5f1606c39 100644 --- a/tests/fortran/conftest.py +++ b/tests/fortran/conftest.py @@ -219,14 +219,6 @@ def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item errors.append( f"fortran_end_to_end path/marker mismatch ({is_end_to_end=}, {has_end_to_end_mark=}): {item.nodeid}" ) - real_library = item.get_closest_marker("real_library") is not None - is_full_library = ( - _relative_test_path(item).as_posix() - == "tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py" - and item.name.startswith("test_full_library_wrapper_imports_every_root_procedure") - ) - if real_library != is_full_library: - errors.append(f"real_library does not identify exactly a full BLAS/LAPACK node: {item.nodeid}") _validate_smoke_item(item, errors) if errors: diff --git a/tests/fortran/modules/end_to_end/test_scalar_module_variable_plan.py b/tests/fortran/modules/end_to_end/test_scalar_module_variable_plan.py index ac2d452fe..9a5454981 100644 --- a/tests/fortran/modules/end_to_end/test_scalar_module_variable_plan.py +++ b/tests/fortran/modules/end_to_end/test_scalar_module_variable_plan.py @@ -21,6 +21,8 @@ module fscalar_module_state_f90 implicit none integer(4), parameter :: nmax = 12 + integer(4), parameter :: computed_limit = kind(1.0) * 2 + character*1, parameter :: prefix = 'D' integer(4) :: counter = 3 real(8), target :: target_scale = 1.5_8 real(8), allocatable :: optional_scale @@ -123,6 +125,8 @@ def test_whole_scalar_module_variable_behavior_uses_canonical_plan( assert {path.name for path in result.generated_sources} == expected_sources assert module.nmax == np.int32(12) + assert module.computed_limit == np.int32(8) + assert module.prefix == "D" assert module.counter == np.int32(3) assert module.target_scale == np.float64(1.5) assert module.optional_scale is None @@ -184,10 +188,13 @@ def test_whole_scalar_module_variable_behavior_uses_canonical_plan( c_source = (build_dir / "fscalar_module_state_f90_wrapper.c").read_text(encoding="utf-8") fortran_source = (build_dir / "bind_c_fscalar_module_state_f90_wrapper.f90").read_text(encoding="utf-8") assert "bind_c_get_counter" in c_source + assert "bind_c_get_computed_limit" in c_source + assert 'PyUnicode_FromString("D")' in c_source assert "bind_c_set_counter" in c_source assert "bind_c_get_optional_scale" in c_source assert "bind_c_get_selected_scale" in c_source assert "function bind_c_get_counter()" in fortran_source + assert "function bind_c_get_computed_limit()" in fortran_source assert "subroutine bind_c_set_counter(" in fortran_source assert "function bind_c_get_optional_scale()" in fortran_source assert "function bind_c_get_selected_scale()" in fortran_source diff --git a/tests/fortran/modules/policy/test_module_variable_policy.py b/tests/fortran/modules/policy/test_module_variable_policy.py index 36af665db..bbd9bd6b8 100644 --- a/tests/fortran/modules/policy/test_module_variable_policy.py +++ b/tests/fortran/modules/policy/test_module_variable_policy.py @@ -5,6 +5,9 @@ complete_semantic_policies, parse_pyi_text, ) +from prik.parsers.fortran.parser import parse_fortran_project +from prik.pipeline.build import _apply_source_python_exports, _merge_wrapper_modules +from prik.semantics.fortran2ir import fortran_project_to_semantic_modules from prik.semantics.models import RESOLVED_MODULE_VARIABLE_POLICY_METADATA from prik.semantics.ownership import AssignmentMode from prik.semantics.wrapper_policy import ModuleGetterAction, ModuleVariablePolicy @@ -50,6 +53,40 @@ def test_scalar_module_variable_policy_completes_access_and_storage_before_plann assert policies["selected_scale"].native_assignment is AssignmentMode.NONE +def test_symbolic_source_parameters_use_native_getters_while_literals_stay_in_binding(): + parsed = parse_fortran_project( + { + "computed_constants.f90": """ +module computed_constants + integer, parameter :: computed = kind(1.0) * 2 + real, parameter :: tolerance = epsilon(0.0) + integer, parameter :: literal = 12 + character*1, parameter :: prefix = 'D' +end module computed_constants +""" + } + ) + modules = fortran_project_to_semantic_modules(parsed) + _apply_source_python_exports(modules) + module = _merge_wrapper_modules(modules, name="computed_constants_wrapper") + + complete_semantic_policies(module) + + policies = { + variable.name: variable.metadata[RESOLVED_MODULE_VARIABLE_POLICY_METADATA] for variable in module.variables + } + assert policies["computed"].getter_action is ModuleGetterAction.NATIVE_CONSTANT_VALUE + assert policies["computed"].constant_value is None + assert policies["computed"].setter_action is SetterAction.OMIT + assert policies["tolerance"].getter_action is ModuleGetterAction.NATIVE_CONSTANT_VALUE + assert policies["tolerance"].constant_value is None + assert policies["literal"].getter_action is ModuleGetterAction.CONSTANT_VALUE + assert policies["literal"].constant_value == 12 + assert policies["prefix"].getter_action is ModuleGetterAction.CONSTANT_VALUE + assert policies["prefix"].constant_value == "D" + assert all(policy.supported for policy in policies.values()) + + def test_fixed_module_array_requires_explicit_addressable_alias_storage(): module = parse_pyi_text( """ diff --git a/tests/fortran/modules/wrapper_codegen/test_scalar_module_variable_lowering.py b/tests/fortran/modules/wrapper_codegen/test_scalar_module_variable_lowering.py index 0da05ee77..9043e2904 100644 --- a/tests/fortran/modules/wrapper_codegen/test_scalar_module_variable_lowering.py +++ b/tests/fortran/modules/wrapper_codegen/test_scalar_module_variable_lowering.py @@ -8,6 +8,9 @@ import pytest from tests.fortran._support.ownership_policy import parse_pyi_text +from prik.parsers.fortran.parser import parse_fortran_project +from prik.pipeline.build import _apply_source_python_exports, _merge_wrapper_modules +from prik.semantics.fortran2ir import fortran_project_to_semantic_modules from prik.semantics.ownership import AssignmentMode, SetterAction from prik.semantics.policy_completion import complete_semantic_policies from prik.semantics.wrapper_policy import ModuleGetterAction @@ -33,6 +36,24 @@ def _plan(): return WrapperPlanner().build(module) +def _computed_constant_plan(): + parsed = parse_fortran_project( + { + "computed_constants.f90": """ +module computed_constants + integer, parameter :: computed = kind(1.0) * 2 + character*1, parameter :: prefix = 'D' +end module computed_constants +""" + } + ) + modules = fortran_project_to_semantic_modules(parsed) + _apply_source_python_exports(modules) + module = _merge_wrapper_modules(modules, name="computed_constants_wrapper") + complete_semantic_policies(module) + return WrapperPlanner().build(module) + + def _source(artifacts, suffix: str) -> str: return next(item.text for item in artifacts.sources if item.path.name.endswith(suffix)) @@ -66,6 +87,28 @@ def test_module_variable_plan_contains_only_completed_dispatch_facts(): assert variables["selected_scale"].bridge.native_assignment is AssignmentMode.NONE +def test_symbolic_source_parameter_reuses_scalar_bridge_getter_for_module_initialization(): + plan = _computed_constant_plan() + variables = {variable.binding.python_names[0]: variable for variable in plan.namespaces[1].variables} + computed = variables["computed"] + assert computed.binding.getter_action is ModuleGetterAction.NATIVE_CONSTANT_VALUE + assert computed.binding.constant_value is None + assert computed.bridge.getter_role == "computed_constants.computed:getter" + assert computed.binding.setter_action is SetterAction.OMIT + + artifacts = WrapperCodeGenerator().generate(plan) + c_source = _source(artifacts, ".c") + fortran_source = _source(artifacts, ".f90") + assert "int32_t bind_c_get_computed(void);" in c_source + assert "int32_t constant_computed_value_0 = bind_c_get_computed();" in c_source + assert 'PyUnicode_FromString("D")' in c_source + assert "native_computed => computed" in fortran_source + assert "function bind_c_get_computed()" in fortran_source + assert "result = native_computed" in fortran_source + assert "bind_c_set_computed" not in c_source + assert "bind_c_set_computed" not in fortran_source + + def test_module_variable_visitors_consume_their_backend_owned_actions(): plan = _plan() counter = next( diff --git a/tests/fortran/source_parsing/parsing/test_declaration_and_scope_regressions.py b/tests/fortran/source_parsing/parsing/test_declaration_and_scope_regressions.py index b65b8c9cf..02b4cffbe 100644 --- a/tests/fortran/source_parsing/parsing/test_declaration_and_scope_regressions.py +++ b/tests/fortran/source_parsing/parsing/test_declaration_and_scope_regressions.py @@ -404,6 +404,33 @@ def test_project_registries_preserve_qualified_aliases_values_and_dependencies() assert project.interfaces["child_mod.child_callback"] is project.interfaces["child_callback"] +@pytest.mark.parametrize("standalone_first", [False, True]) +def test_standalone_procedure_owns_unqualified_name_shared_with_module_member(standalone_first): + module_source = """ +module nan_mod +contains + logical function sisnan(value) + real, intent(in) :: value + end function sisnan +end module nan_mod +""" + standalone_source = """ +logical function sisnan(value) + real, intent(in) :: value +end function sisnan +""" + sources = [("standalone.f90", standalone_source), ("module.f90", module_source)] + if not standalone_first: + sources.reverse() + + project = parse_fortran_project(dict(sources)) + module_procedure = project.modules["nan_mod"].procedures[0] + standalone_procedure = next(procedure for parsed_file in project.files for procedure in parsed_file.procedures) + + assert project.procedures["nan_mod.sisnan"] is module_procedure + assert project.procedures["sisnan"] is standalone_procedure + + def test_parse_file_preserves_top_level_models_but_limits_file_symbol_registry(): parsed = FortranParser().parse_file( """ diff --git a/tests/fortran/source_parsing/parsing/test_parser_benchmarks.py b/tests/fortran/source_parsing/parsing/test_parser_benchmarks.py index fb8096162..3e85a35ef 100644 --- a/tests/fortran/source_parsing/parsing/test_parser_benchmarks.py +++ b/tests/fortran/source_parsing/parsing/test_parser_benchmarks.py @@ -37,15 +37,7 @@ def test_parse_convert_emit_representative_fortran_module(benchmark): @pytest.mark.benchmark def test_parse_real_lapack_dgesv(benchmark): - source = ( - Path(__file__).resolve().parents[2] - / "building_shared_library" - / "end_to_end" - / "real_libraries" - / "lapack" - / "native" - / "dgesv.f" - ).read_text( + source = (Path(__file__).resolve().parents[4] / "examples" / "lapack" / "native" / "dgesv.f").read_text( encoding="utf-8", ) parsed = benchmark(parse_fortran_file, source, filename="lapack/dgesv.f") diff --git a/tests/fortran/source_parsing/parsing/test_real_world_interaction_regressions.py b/tests/fortran/source_parsing/parsing/test_real_world_interaction_regressions.py index 0513aeb1b..46326d399 100644 --- a/tests/fortran/source_parsing/parsing/test_real_world_interaction_regressions.py +++ b/tests/fortran/source_parsing/parsing/test_real_world_interaction_regressions.py @@ -34,6 +34,7 @@ def test_legacy_and_extended_types_keep_initializers_and_declaration_attributes( integer, parameter :: truth = 1 < 2 real, parameter :: scale = 1.25d0 character(len=*), parameter :: label = "timer" + character*1, parameter :: prefix = 'D' complex, parameter :: imaginary = (0.d0, 1.d0) end module declaration_interactions """, @@ -52,6 +53,9 @@ def test_legacy_and_extended_types_keep_initializers_and_declaration_attributes( assert variables["truth"].value == "1" assert variables["scale"].value == "1.25d0" assert variables["label"].value == '"timer"' + assert variables["prefix"].is_parameter is True + assert variables["prefix"].value == "'D'" + assert variables["prefix"].symbolic_value == "'D'" assert variables["imaginary"].value == "(0.d0, 1.d0)" diff --git a/tests/shared/architecture/test_test_suite_layout.py b/tests/shared/architecture/test_test_suite_layout.py index 680f6406a..d4c6e69d0 100644 --- a/tests/shared/architecture/test_test_suite_layout.py +++ b/tests/shared/architecture/test_test_suite_layout.py @@ -2,26 +2,32 @@ from __future__ import annotations +import ast import re from pathlib import Path REPO_ROOT = Path(__file__).parents[3] TEST_ROOT = REPO_ROOT / "tests" +EXAMPLES_ROOT = REPO_ROOT / "examples" TEST_INDEX = TEST_ROOT / "README.md" +WORKFLOW_ROOT = REPO_ROOT / ".github/workflows" BLAS_LAPACK_WORKFLOW = REPO_ROOT / ".github/workflows/blas-lapack.yml" CLAUDE_WORKFLOW = REPO_ROOT / ".github/workflows/claude.yml" COVERAGE_WORKFLOW = REPO_ROOT / ".github/workflows/coverage.yml" CODECOV_CONFIG = REPO_ROOT / "codecov.yml" DOCS_WORKFLOW = REPO_ROOT / ".github/workflows/docs.yml" -PARSER_REFERENCE_WORKFLOW = REPO_ROOT / ".github/workflows/parser-reference-guard.yml" +FORTRAN_SMOKE_WORKFLOW = REPO_ROOT / ".github/workflows/fortran-toolchain-smoke.yml" +MERGE_VALIDATION_WORKFLOW = REPO_ROOT / ".github/workflows/merge-validation.yml" PUBLISH_WORKFLOW = REPO_ROOT / ".github/workflows/publish-to-pypi.yml" STATIC_ANALYSIS_WORKFLOW = REPO_ROOT / ".github/workflows/static-analysis.yml" TESTS_WORKFLOW = REPO_ROOT / ".github/workflows/tests.yml" +QUALITY_ASSURANCE_DOC = REPO_ROOT / "docs/developer/quality-assurance.md" PYPROJECT = REPO_ROOT / "pyproject.toml" CHANGELOG = REPO_ROOT / "CHANGELOG.md" MANIFEST = REPO_ROOT / "MANIFEST.in" -FULL_REAL_LIBRARY_TEST = "tests/fortran/building_shared_library/end_to_end/real_libraries/test_full_libraries.py" +BLAS_CI_FULL_SURFACE = "examples/blas/ci/full_surface.py" +LAPACK_CI_FULL_SURFACE = "examples/lapack/ci/full_surface.py" LEGACY_TEST_ROOTS = { "benchmarks", @@ -115,6 +121,52 @@ def _maintained_path_reference_files() -> list[Path]: ) +def _github_action_job_display_names(workflow: Path) -> dict[str, str]: + names: dict[str, str] = {} + current_job: str | None = None + in_jobs = False + for line in workflow.read_text(encoding="utf-8").splitlines(): + if line == "jobs:": + in_jobs = True + continue + if not in_jobs: + continue + job_match = re.fullmatch(r" ([a-z0-9-]+):", line) + if job_match: + current_job = job_match.group(1) + continue + if current_job is not None and line.startswith(" name: "): + names[current_job] = line.removeprefix(" name: ") + return names + + +def _github_action_workflow_name(workflow: Path) -> str: + first_line = workflow.read_text(encoding="utf-8").splitlines()[0] + assert first_line.startswith("name: ") + return first_line.removeprefix("name: ") + + +def _github_matrix_display_names(workflow: Path) -> tuple[str, ...]: + prefix = "display_name: " + return tuple( + line.strip().removeprefix(prefix) + for line in workflow.read_text(encoding="utf-8").splitlines() + if line.strip().startswith(prefix) + ) + + +def _github_action_job_block(workflow: Path, job_id: str) -> str: + remainder = workflow.read_text(encoding="utf-8").split(f" {job_id}:\n", maxsplit=1)[1] + next_job = re.search(r"\n [a-z0-9-]+:\n", remainder) + return remainder if next_job is None else remainder[: next_job.start()] + + +def _github_action_job_steps(workflow: Path, job_id: str) -> tuple[str, ...]: + block = _github_action_job_block(workflow, job_id) + steps = block.split(" steps:\n", maxsplit=1)[1] + return tuple(line for line in steps.splitlines() if line.strip()) + + def test_pytest_modules_have_one_allowed_primary_owner() -> None: root_modules = sorted(path.name for path in TEST_ROOT.glob("test_*.py")) assert root_modules == [] @@ -165,6 +217,51 @@ def test_fortran_support_directory_contains_no_pytest_modules() -> None: assert sorted((TEST_ROOT / "fortran" / "_support").rglob("test_*.py")) == [] +def test_native_library_examples_are_copyable_without_the_repository_test_package() -> None: + assert (EXAMPLES_ROOT / "__init__.py").is_file() + assert (EXAMPLES_ROOT / "conftest.py").is_file() + assert (EXAMPLES_ROOT / "blas" / "__init__.py").is_file() + assert (EXAMPLES_ROOT / "lapack" / "__init__.py").is_file() + + repository_test_imports = [] + for path in sorted(EXAMPLES_ROOT.rglob("*.py")): + tree = ast.parse(path.read_text(encoding="utf-8"), filename=str(path)) + for node in ast.walk(tree): + if isinstance(node, ast.ImportFrom) and node.module is not None and node.module.startswith("tests"): + repository_test_imports.append(f"{path.relative_to(REPO_ROOT)}: {node.module}") + if isinstance(node, ast.Import): + repository_test_imports.extend( + f"{path.relative_to(REPO_ROOT)}: {alias.name}" + for alias in node.names + if alias.name.startswith("tests") + ) + assert repository_test_imports == [] + + +def test_native_library_examples_separate_user_tests_from_ci_audits() -> None: + fixture_names = { + "blas": {"prik_blas", "f2py_blas"}, + "lapack": {"prik_lapack", "f2py_lapack", "scipy_lapack"}, + } + for library, expected_fixtures in fixture_names.items(): + root = EXAMPLES_ROOT / library + assert (root / "tests" / "helpers.py").is_file() + assert sorted((root / "tests").glob("test_*.py")) + assert {path.name for path in (root / "ci").glob("*.py")} == { + "__init__.py", + "full_surface.py", + } + assert all((root / script).is_file() for script in ("build_prik.sh", "build_f2py.sh", "build_all.sh")) + + aggregate = (root / "build_all.sh").read_text(encoding="utf-8") + assert f"source examples/{library}/build_prik.sh" in aggregate + assert f'source "$EXAMPLE_WORKSPACE/examples/{library}/build_f2py.sh"' in aggregate + + fixture_tree = ast.parse((root / "conftest.py").read_text(encoding="utf-8")) + functions = {node.name for node in fixture_tree.body if isinstance(node, ast.FunctionDef)} + assert functions == expected_fixtures + + def test_test_index_links_and_language_directories_exist() -> None: text = TEST_INDEX.read_text(encoding="utf-8") for target in re.findall(r"\[[^]]+\]\(([^)#]+)", text): @@ -183,21 +280,25 @@ def test_maintained_docs_do_not_name_deprecated_pytest_locations() -> None: assert stale == [] -def test_full_real_library_nodes_have_one_dedicated_workflow() -> None: +def test_real_library_examples_have_one_dedicated_workflow() -> None: ordinary_jobs = TESTS_WORKFLOW.read_text(encoding="utf-8") dedicated_job = BLAS_LAPACK_WORKFLOW.read_text(encoding="utf-8") assert '-m "not real_library and not toolchain_smoke"' in ordinary_jobs assert ordinary_jobs.count('-m "not real_library and not toolchain_smoke"') == 2 - assert FULL_REAL_LIBRARY_TEST not in ordinary_jobs - assert ( - f'"{FULL_REAL_LIBRARY_TEST}::test_full_library_wrapper_imports_every_root_procedure_from_cached_shared_library[blas]"' - in dedicated_job - ) - assert ( - f'"{FULL_REAL_LIBRARY_TEST}::test_full_library_wrapper_imports_every_root_procedure_from_cached_shared_library[lapack]"' - in dedicated_job - ) + assert "examples/blas" not in ordinary_jobs + assert "examples/lapack" not in ordinary_jobs + assert "source examples/blas/build_all.sh" in dedicated_job + assert "source examples/lapack/build_all.sh" in dedicated_job + assert f"python -m pytest -q examples/blas/tests {BLAS_CI_FULL_SURFACE}" in dedicated_job + assert f"python -m pytest -q examples/lapack/tests {LAPACK_CI_FULL_SURFACE}" in dedicated_job + assert BLAS_CI_FULL_SURFACE in dedicated_job + assert LAPACK_CI_FULL_SURFACE in dedicated_job + assert '"meson==1.11.2"' in dedicated_job + assert '"ninja==1.13.0"' in dedicated_job + assert '"scipy==1.18.0"' in dedicated_job + assert "libblas-dev" in dedicated_job + assert "liblapack-dev" in dedicated_job assert "ignore-real-library-wrappers" in dedicated_job assert "matrix.library" not in dedicated_job @@ -237,50 +338,182 @@ def test_codecov_keeps_project_coverage_blocking_and_patch_coverage_informationa ) -def test_active_github_action_jobs_use_purpose_first_display_names() -> None: +def test_active_github_action_checks_use_distinct_workflow_scopes_and_job_names() -> None: + workflow_names = { + BLAS_LAPACK_WORKFLOW: "Native Libraries", + CLAUDE_WORKFLOW: "Repository Automation", + COVERAGE_WORKFLOW: "Quality Metrics", + DOCS_WORKFLOW: "Documentation", + FORTRAN_SMOKE_WORKFLOW: "Compiler Compatibility", + MERGE_VALIDATION_WORKFLOW: "Pull Request", + PUBLISH_WORKFLOW: "Release Automation", + STATIC_ANALYSIS_WORKFLOW: "Code Quality", + TESTS_WORKFLOW: "Test Matrix", + } expected = { - DOCS_WORKFLOW: ( - "name: Documentation", - " name: Benchmark", - " name: Build", - " name: Deploy", - ), - PARSER_REFERENCE_WORKFLOW: ( - "name: Parser Reference", - " name: Guard", - ), - STATIC_ANALYSIS_WORKFLOW: ( - "name: Static Analysis", - " name: Python 3.12", - ), - TESTS_WORKFLOW: ( - "name: Tests", - " name: Python ${{ matrix.python-version }}", - " name: macOS 15 ARM64 · Python 3.12", - ), - BLAS_LAPACK_WORKFLOW: ( - "name: BLAS + LAPACK", - " name: Python 3.12", - ), - COVERAGE_WORKFLOW: ( - "name: Coverage", - " name: Python 3.12", - ), - PUBLISH_WORKFLOW: ( - "name: Publish to PyPI", - " name: Build and validate distributions", - " name: Publish distributions", - ), - CLAUDE_WORKFLOW: ( - "name: Claude Code", - " name: Respond", - ), + BLAS_LAPACK_WORKFLOW: {"real-library-wrappers": "BLAS + LAPACK · Ubuntu 24.04 · Python 3.12"}, + CLAUDE_WORKFLOW: {"claude": "Claude Code response to mention"}, + COVERAGE_WORKFLOW: {"coverage": "Project coverage · Ubuntu 24.04 · Python 3.12"}, + DOCS_WORKFLOW: { + "benchmark": "Documentation performance benchmark · Ubuntu 24.04 ARM64 · Python 3.12", + "build": "Documentation site build · Ubuntu 24.04 · Python 3.12", + "deploy": "Documentation deployment · GitHub Pages", + }, + FORTRAN_SMOKE_WORKFLOW: { + "toolchain-smoke": "Compiler smoke · ${{ matrix.display_name }}", + "macos-flang-smoke": "Compiler smoke · macOS 15 ARM64 · LLVM Flang · Python 3.12", + }, + MERGE_VALIDATION_WORKFLOW: { + "static-analysis": "Static analysis · Ubuntu 24.04 · Python 3.12", + "parser-reference-guard": "Parser reference guard · Ubuntu 24.04", + "compiler-smoke": "Compiler smoke · ${{ matrix.display_name }}", + "compiler-smoke-macos": "Compiler smoke · macOS 15 ARM64 · LLVM Flang · Python 3.12", + "unit-tests": "${{ matrix.display_name }}", + "unit-tests-macos": "Unit tests · macOS 15 ARM64 · Python 3.12", + "native-libraries": "BLAS + LAPACK · Ubuntu 24.04 · Python 3.12", + "documentation-benchmark": "Documentation performance benchmark · Ubuntu 24.04 ARM64 · Python 3.12", + "documentation-build": "Documentation site build · Ubuntu 24.04 · Python 3.12", + "merge-gate": "Validation · all required checks", + }, + PUBLISH_WORKFLOW: { + "build": "PyPI distribution build · Ubuntu 24.04 · Python 3.12", + "publish": "PyPI trusted publishing · pypi", + }, + STATIC_ANALYSIS_WORKFLOW: {"static-analysis": "Static analysis · Ubuntu 24.04 · Python 3.12"}, + TESTS_WORKFLOW: { + "test": "Unit tests · Ubuntu 24.04 · Python ${{ matrix.python-version }}", + "macos": "Unit tests · macOS 15 ARM64 · Python 3.12", + }, } - for workflow, names in expected.items(): + assert set(workflow_names) == set(expected) == set(WORKFLOW_ROOT.glob("*.yml")) + assert {workflow: _github_action_workflow_name(workflow) for workflow in workflow_names} == workflow_names + assert len(workflow_names.values()) == len(set(workflow_names.values())) + assert {workflow: _github_action_job_display_names(workflow) for workflow in expected} == expected + + display_names = [name for jobs in expected.values() for name in jobs.values()] + check_contexts = [ + f"{workflow_names[workflow]} / {job_name}" for workflow, jobs in expected.items() for job_name in jobs.values() + ] + assert len(check_contexts) == len(set(check_contexts)) + assert all(not re.fullmatch(r"Python(?:\s+.*)?", name) for name in display_names) + + smoke_matrix_names = _github_matrix_display_names(FORTRAN_SMOKE_WORKFLOW) + assert smoke_matrix_names == ( + "Ubuntu 24.04 · Intel IFX 2026.1.1 · Python 3.12", + "Ubuntu 24.04 · LLVM Flang 22.1.8 · Python 3.12", + ) + assert 'python-version: ["3.10", "3.11", "3.12"]' in TESTS_WORKFLOW.read_text(encoding="utf-8") + documented_contexts = ("Pull Request / Validation · all required checks",) + quality_assurance = QUALITY_ASSURANCE_DOC.read_text(encoding="utf-8") + assert len(documented_contexts) == len(set(documented_contexts)) + for context in documented_contexts: + assert f"`{context}`" in quality_assurance + + +def test_pull_request_declares_direct_staged_jobs_and_always_reports_the_gate() -> None: + workflow = MERGE_VALIDATION_WORKFLOW.read_text(encoding="utf-8") + + assert workflow.startswith("name: Pull Request\n") + assert " pull_request:\n types: [opened, synchronize, reopened, labeled, unlabeled]" in workflow + assert "group: pull-request-${{ github.ref }}" in workflow + assert "cancel-in-progress: true" in workflow + assert "uses: ./.github/workflows/" not in workflow + + for job_id in ("static-analysis", "parser-reference-guard"): + block = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, job_id) + assert "needs:" not in block + assert "runs-on:" in block + + for job_id in ("compiler-smoke", "compiler-smoke-macos"): + block = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, job_id) + assert "needs: [static-analysis, parser-reference-guard]" in block + assert "runs-on:" in block + + for job_id in ("unit-tests", "unit-tests-macos"): + block = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, job_id) + assert "needs: [compiler-smoke, compiler-smoke-macos]" in block + assert "runs-on:" in block + + unit_tests = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, "unit-tests") + assert "Unit tests + project coverage · Ubuntu 24.04 · Python 3.12" in unit_tests + assert "python -m coverage combine" in unit_tests + assert "python -m coverage report" in unit_tests + assert "uses: codecov/codecov-action@v6" in unit_tests + assert "id-token: write" in unit_tests + + native_libraries = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, "native-libraries") + assert "needs: [unit-tests, unit-tests-macos]" in native_libraries + assert "ignore-real-library-wrappers" in native_libraries + assert "source examples/blas/build_all.sh" in native_libraries + assert "source examples/lapack/build_all.sh" in native_libraries + assert f"python -m pytest -q examples/blas/tests {BLAS_CI_FULL_SURFACE}" in native_libraries + assert f"python -m pytest -q examples/lapack/tests {LAPACK_CI_FULL_SURFACE}" in native_libraries + assert BLAS_CI_FULL_SURFACE in native_libraries + assert LAPACK_CI_FULL_SURFACE in native_libraries + + benchmark = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, "documentation-benchmark") + assert "needs: native-libraries" in benchmark + assert "always()" in benchmark + assert "bash benchmarks/run.sh" in benchmark + + documentation = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, "documentation-build") + assert "needs: documentation-benchmark" in documentation + assert "python -m pytest -q tests/shared/docs" in documentation + assert "python -m mkdocs build --strict" in documentation + + gate = _github_action_job_block(MERGE_VALIDATION_WORKFLOW, "merge-gate") + assert "if: ${{ always() }}" in gate + for dependency in ( + "static-analysis", + "parser-reference-guard", + "compiler-smoke", + "compiler-smoke-macos", + "unit-tests", + "unit-tests-macos", + "native-libraries", + "documentation-benchmark", + "documentation-build", + ): + assert f" - {dependency}" in gate + assert f"needs.{dependency}.result" in gate + assert 'if [[ "$result" != "success" ]]' in gate + assert 'exit "$failed"' in gate + + +def test_purpose_specific_workflows_do_not_create_duplicate_pull_request_runs() -> None: + for workflow in ( + TESTS_WORKFLOW, + STATIC_ANALYSIS_WORKFLOW, + BLAS_LAPACK_WORKFLOW, + FORTRAN_SMOKE_WORKFLOW, + COVERAGE_WORKFLOW, + DOCS_WORKFLOW, + ): text = workflow.read_text(encoding="utf-8") - for name in names: - assert name in text + assert " workflow_call:" not in text + assert " pull_request:" not in text + + assert "run-coverage" not in COVERAGE_WORKFLOW.read_text(encoding="utf-8") + + +def test_pull_request_jobs_share_the_reviewed_component_workflow_steps() -> None: + for pull_request_job, component_workflow, component_job in ( + ("static-analysis", STATIC_ANALYSIS_WORKFLOW, "static-analysis"), + ("compiler-smoke", FORTRAN_SMOKE_WORKFLOW, "toolchain-smoke"), + ("compiler-smoke-macos", FORTRAN_SMOKE_WORKFLOW, "macos-flang-smoke"), + ("unit-tests-macos", TESTS_WORKFLOW, "macos"), + ("native-libraries", BLAS_LAPACK_WORKFLOW, "real-library-wrappers"), + ("documentation-benchmark", DOCS_WORKFLOW, "benchmark"), + ): + assert _github_action_job_steps(MERGE_VALIDATION_WORKFLOW, pull_request_job) == _github_action_job_steps( + component_workflow, component_job + ) + + pull_request_build = _github_action_job_steps(MERGE_VALIDATION_WORKFLOW, "documentation-build") + main_build = _github_action_job_steps(DOCS_WORKFLOW, "build") + configure_pages = main_build.index(" - name: Configure GitHub Pages") + assert pull_request_build == main_build[:configure_pages] def test_pypi_package_identity_is_complete_and_consistent() -> None: @@ -341,22 +574,31 @@ def test_static_analysis_targets_the_renamed_package_tree() -> None: assert removed_root not in workflow -def test_documentation_workflow_generates_main_only_performance_snapshot() -> None: - workflow = DOCS_WORKFLOW.read_text(encoding="utf-8") - - assert "group: documentation-${{ github.ref }}" in workflow - assert "cancel-in-progress: ${{ github.event_name == 'pull_request' }}" in workflow - assert "runs-on: ubuntu-24.04-arm" in workflow - assert "if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'" in workflow - assert "python tools/benchmark_host.py" in workflow - assert "--require-machine aarch64" in workflow - assert "--require-arm-part 0xd49" in workflow - assert '--github-env "$GITHUB_ENV"' in workflow - assert "bash benchmarks/run.sh" in workflow - assert "python tools/generate_performance_docs.py" in workflow - assert "name: performance-snapshot" in workflow - assert "benchmarks/results/f2py.json" in workflow - assert "benchmarks/results/prik.json" in workflow - assert "benchmarks/results/f2py-build.json" in workflow - assert "benchmarks/results/prik-build.json" in workflow - assert "uses: actions/download-artifact@v4" in workflow +def test_pull_request_and_main_generate_equivalent_documentation_performance_snapshots() -> None: + pull_request = MERGE_VALIDATION_WORKFLOW.read_text(encoding="utf-8") + main = DOCS_WORKFLOW.read_text(encoding="utf-8") + + assert "group: documentation-${{ github.ref }}" in main + assert "cancel-in-progress: true" in main + assert " workflow_call:" not in main + for declaration in ( + "runs-on: ubuntu-24.04-arm", + "python tools/benchmark_host.py", + "--require-machine aarch64", + "--require-arm-part 0xd49", + '--github-env "$GITHUB_ENV"', + "bash benchmarks/run.sh", + "python tools/generate_performance_docs.py", + "name: performance-snapshot", + "benchmarks/results/f2py.json", + "benchmarks/results/prik.json", + "benchmarks/results/f2py-build.json", + "benchmarks/results/prik-build.json", + "uses: actions/download-artifact@v4", + "python -m pytest -q tests/shared/docs", + "python -m mkdocs build --strict", + ): + assert declaration in pull_request + assert declaration in main + + assert main.count("github.ref == 'refs/heads/main' && github.event_name != 'pull_request'") == 3 diff --git a/tests/shared/docs/test_examples.py b/tests/shared/docs/test_examples.py index 5b4339a6d..da6b1278d 100644 --- a/tests/shared/docs/test_examples.py +++ b/tests/shared/docs/test_examples.py @@ -20,6 +20,8 @@ ROOT = Path(__file__).parents[3] DOC_PATHS = [ ROOT / "README.md", + ROOT / "examples/blas/README.md", + ROOT / "examples/lapack/README.md", *sorted(path for path in (ROOT / "docs").rglob("*.md") if "old_docs" not in path.parts), ] AUDITED_PYTHON_DOC_PATHS = [ @@ -64,6 +66,7 @@ class DocumentedSource: path: Path line: int source_path: Path + selector: str | None source_text: str @property @@ -148,11 +151,14 @@ def _documented_content_from_path(path: Path) -> tuple[list[DocumentationExample if source_marker is not None: marker_line = index + 1 source_text, index, _language = _fenced_block(lines, index + 1) + source_reference = source_marker.group(1) + source_path, separator, selector = source_reference.partition("::") sources.append( DocumentedSource( path=path, line=marker_line, - source_path=ROOT / source_marker.group(1), + source_path=ROOT / source_path, + selector=selector if separator else None, source_text=source_text, ) ) @@ -263,7 +269,14 @@ def test_documentation_has_automatically_verified_examples(): @pytest.mark.parametrize("source", DOCUMENTED_SOURCES, ids=lambda source: source.test_id) def test_documented_source_input(source: DocumentedSource): assert source.source_path.is_file(), f"{source.test_id}: documented source does not exist: {source.source_path}" - assert source.source_text.rstrip("\n") == source.source_path.read_text(encoding="utf-8").rstrip("\n") + file_text = source.source_path.read_text(encoding="utf-8") + expected_text = file_text + if source.selector is not None: + tree = ast.parse(file_text, filename=str(source.source_path)) + selected = [node for node in tree.body if isinstance(node, ast.FunctionDef) and node.name == source.selector] + assert len(selected) == 1, f"{source.test_id}: source selector {source.selector!r} did not name one function" + expected_text = ast.get_source_segment(file_text, selected[0]) or "" + assert source.source_text.rstrip("\n") == expected_text.rstrip("\n") @pytest.mark.parametrize("block", DOCUMENTED_PYTHON_BLOCKS, ids=lambda block: block.test_id) diff --git a/tests/shared/tools/test_warm_real_library_native_cache.py b/tests/shared/tools/test_warm_real_library_native_cache.py index d71d38ae1..62ccf0041 100644 --- a/tests/shared/tools/test_warm_real_library_native_cache.py +++ b/tests/shared/tools/test_warm_real_library_native_cache.py @@ -7,16 +7,16 @@ def test_warm_real_library_native_cache_defaults_to_all_libraries(monkeypatch, capsys): calls = [] - def cached_native_shared_library(library: str) -> Path: + def build_reference_library(library: str): calls.append(library) - return Path("/cache") / f"libprik_full_{library}.so" + return SimpleNamespace(shared_library=Path("/cache") / f"libprik_full_{library}.so") monkeypatch.setattr( warm_real_library_native_cache, - "_real_library_cache_module", + "_native_library_module", lambda: SimpleNamespace( - _native_cache_root=lambda: Path("/cache"), - _cached_native_shared_library=cached_native_shared_library, + native_cache_root=lambda: Path("/cache"), + build_reference_library=build_reference_library, ), ) @@ -33,16 +33,16 @@ def cached_native_shared_library(library: str) -> Path: def test_warm_real_library_native_cache_accepts_selected_libraries(monkeypatch, capsys): calls = [] - def cached_native_shared_library(library: str) -> Path: + def build_reference_library(library: str): calls.append(library) - return Path("/cache") / f"libprik_full_{library}.so" + return SimpleNamespace(shared_library=Path("/cache") / f"libprik_full_{library}.so") monkeypatch.setattr( warm_real_library_native_cache, - "_real_library_cache_module", + "_native_library_module", lambda: SimpleNamespace( - _native_cache_root=lambda: Path("/cache"), - _cached_native_shared_library=cached_native_shared_library, + native_cache_root=lambda: Path("/cache"), + build_reference_library=build_reference_library, ), ) @@ -58,10 +58,10 @@ def cached_native_shared_library(library: str) -> Path: def test_warm_real_library_native_cache_rejects_unknown_library(monkeypatch): monkeypatch.setattr( warm_real_library_native_cache, - "_real_library_cache_module", + "_native_library_module", lambda: SimpleNamespace( - _native_cache_root=lambda: Path("/cache"), - _cached_native_shared_library=lambda library: Path("/cache") / library, + native_cache_root=lambda: Path("/cache"), + build_reference_library=lambda library: SimpleNamespace(shared_library=Path("/cache") / library), ), ) diff --git a/tools/warm_real_library_native_cache.py b/tools/warm_real_library_native_cache.py index 5deacf501..bfacd97aa 100644 --- a/tools/warm_real_library_native_cache.py +++ b/tools/warm_real_library_native_cache.py @@ -11,13 +11,11 @@ DEFAULT_LIBRARIES = ("blas", "lapack") -def _real_library_cache_module(): +def _native_library_module(): repo_root = Path(__file__).resolve().parents[1] if str(repo_root) not in sys.path: sys.path.insert(0, str(repo_root)) - return importlib.import_module( - "tests.fortran.building_shared_library.end_to_end.real_libraries.test_full_libraries" - ) + return importlib.import_module("examples.native_library") def main(argv: Sequence[str] | None = None) -> int: @@ -39,11 +37,11 @@ def main(argv: Sequence[str] | None = None) -> int: + " (choose from blas, lapack)" ) - cache_module = _real_library_cache_module() - print(f"native cache root: {cache_module._native_cache_root()}") + native_library = _native_library_module() + print(f"native cache root: {native_library.native_cache_root()}") for library in libraries: - shared = cache_module._cached_native_shared_library(library) - print(f"{library}: {shared}") + build = native_library.build_reference_library(library) + print(f"{library}: {build.shared_library}") return 0