diff --git a/.clang-format b/.clang-format index d092c0781..3cdca3d53 100644 --- a/.clang-format +++ b/.clang-format @@ -85,6 +85,6 @@ SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: false SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: c++14 +Standard: c++20 TabWidth: '4' UseTab: Never diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml new file mode 100644 index 000000000..9ec6f8f33 --- /dev/null +++ b/.github/workflows/benchmarks.yml @@ -0,0 +1,73 @@ +name: benchmarks +on: + workflow_dispatch: + pull_request: + push: + branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true +defaults: + run: + shell: bash -e -l {0} +jobs: + build: + runs-on: ubuntu-24.04 + name: ${{ matrix.sys.compiler }} ${{ matrix.sys.version }} - ${{ matrix.sys.name }} + strategy: + fail-fast: false + matrix: + sys: + - {compiler: clang, version: '20', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON} + - {compiler: clang, version: '20', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} + - {compiler: gcc, version: '14', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON} + - {compiler: gcc, version: '14', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} + + steps: + - name: Install GCC + if: matrix.sys.compiler == 'gcc' + uses: egor-tensin/setup-gcc@v1 + with: + version: ${{matrix.sys.version}} + platform: x64 + + - name: Install LLVM and Clang + if: matrix.sys.compiler == 'clang' + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{matrix.sys.version}} + sudo apt-get install -y clang-tools-${{matrix.sys.version}} + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{matrix.sys.version}} 200 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{matrix.sys.version}} 200 + sudo update-alternatives --install /usr/bin/clang-scan-deps clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} 200 + sudo update-alternatives --set clang /usr/bin/clang-${{matrix.sys.version}} + sudo update-alternatives --set clang++ /usr/bin/clang++-${{matrix.sys.version}} + sudo update-alternatives --set clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + create-args: | + ${{ (matrix.sys.name == 'tbb' || matrix.sys.name == 'xsimd-tbb' ) && 'tbb-devel' || '' }} + + - name: Configure using CMake + run: | + if [[ "${{matrix.sys.compiler}}" = "gcc" ]]; then export CC=gcc-${{matrix.sys.version}}; export CXX=g++-${{matrix.sys.version}}; else export CC=clang; export CXX=clang++; fi + cmake -G Ninja -Bbuild -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_BENCHMARK=ON ${{ matrix.sys.flags }} + + - name: Build + working-directory: build + run: cmake --build . --target benchmark_xtensor --parallel 8 + + - name: Run benchmark + timeout-minutes: 10 # Consider increasing timeout + working-directory: build/benchmark + run: ./benchmark_xtensor diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml new file mode 100644 index 000000000..05d385180 --- /dev/null +++ b/.github/workflows/codspeed.yml @@ -0,0 +1,52 @@ +name: CodSpeed + +on: + push: + branches: [master] + pull_request: # Allow CodSpeed to trigger backtest performance analysis + + workflow_dispatch: + + +permissions: + contents: read + id-token: write + +concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true + +defaults: + run: + shell: bash -e -l {0} + +jobs: + benchmarks: + name: Run benchmarks + runs-on: namespace-profile-benchmark;container.privileged=true;container.host-pid-namespace=true + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + + - name: Build benchmarks + run: | + cmake -G Ninja -Bbuild \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ + -DBUILD_BENCHMARK=ON \ + -DXTENSOR_USE_XSIMD=ON \ + -DCODSPEED_MODE=simulation + cmake --build build --target benchmark_xtensor --parallel 8 + + - name: Run benchmarks + uses: CodSpeedHQ/action@v4 + with: + mode: simulation + run: ./build/benchmark/benchmark_xtensor diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 0dc90f4f3..f86b5256a 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -24,11 +24,13 @@ jobs: - name: Basic GitHub action setup uses: actions/checkout@v2 - - name: Set mamba environment "test" - uses: mamba-org/provision-with-micromamba@main + - name: Set mamba environment + uses: mamba-org/setup-micromamba@main with: environment-file: docs/ghp_environment.yml environment-name: xtensor-doc + init-shell: bash + cache-downloads: true - name: Run doxygen working-directory: docs diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 97d8cb094..1a66aa273 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -12,55 +12,67 @@ defaults: shell: bash -e -l {0} jobs: build: - runs-on: ubuntu-20.04 - name: ${{ matrix.sys.compiler }} ${{ matrix.sys.version }} - ${{ matrix.sys.name }} + runs-on: ${{ matrix.os }} + name: ${{ matrix.os }} ${{ matrix.sys.compiler }} ${{ matrix.sys.version }} - ${{ matrix.sys.name }} strategy: fail-fast: false matrix: + os: [ubuntu-24.04, ubuntu-24.04-arm] sys: - - {compiler: clang, version: '15', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} - - {compiler: clang, version: '16', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} - - {compiler: gcc, version: '8', name: openmp, flags: -DXTENSOR_USE_OPENMP=ON} - - {compiler: gcc, version: '9', name: noexcept, flags: -DXTENSOR_DISABLE_EXCEPTIONS=ON} - - {compiler: gcc, version: '10', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON} - - {compiler: gcc, version: '11', name: c++17, flags: -DCPP17=ON} - - {compiler: gcc, version: '11', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} - - {compiler: gcc, version: '11', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} + - {compiler: clang, version: '17', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} + - {compiler: clang, version: '18', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} + - {compiler: clang, version: '19', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} + - {compiler: clang, version: '20', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} + - {compiler: clang, version: '21', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} + - {compiler: clang, version: '21', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} + - {compiler: clang, version: '22', name: assert, flags: -DXTENSOR_ENABLE_ASSERT=ON} + - {compiler: clang, version: '22', name: column-major, flags: -DDEFAULT_COLUMN_MAJOR=ON} + - {compiler: gcc, version: '11', name: openmp, flags: -DXTENSOR_USE_OPENMP=ON} + - {compiler: gcc, version: '11', name: noexcept, flags: -DXTENSOR_DISABLE_EXCEPTIONS=ON} + - {compiler: gcc, version: '12', name: xsimd, flags: -DXTENSOR_USE_XSIMD=ON} + - {compiler: gcc, version: '13', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} + - {compiler: gcc, version: '13', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} + - {compiler: gcc, version: '14', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} + - {compiler: gcc, version: '14', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} + # TODO: Activate following gcc versions when switching github runner to ubuntu 26.04 + # - {compiler: gcc, version: '15', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} + # - {compiler: gcc, version: '15', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} + # - {compiler: gcc, version: '16', name: xsimd-tbb, flags: -DXTENSOR_USE_XSIMD=ON -DXTENSOR_USE_TBB=ON} + # - {compiler: gcc, version: '16', name: tbb, flags: -DXTENSOR_USE_TBB=ON -DTBB_INCLUDE_DIR=$CONDA_PREFIX/include -DTBB_LIBRARY=$CONDA_PREFIX/lib} + exclude: + - os: ubuntu-24.04-arm + sys: + compiler: gcc + version: '12' + - os: ubuntu-24.04-arm + sys: + compiler: gcc + version: '11' steps: + - name: Install GCC + if: matrix.sys.compiler == 'gcc' + uses: egor-tensin/setup-gcc@v2 + with: + version: ${{matrix.sys.version}} + platform: x64 - - name: Setup GCC - if: ${{ matrix.sys.compiler == 'gcc' }} - run: | - GCC_VERSION=${{ matrix.sys.version }} - sudo apt-get update - sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION - CC=gcc-$GCC_VERSION - echo "CC=$CC" >> $GITHUB_ENV - CXX=g++-$GCC_VERSION - echo "CXX=$CXX" >> $GITHUB_ENV - - - name: Setup clang - if: ${{ matrix.sys.compiler == 'clang' }} + - name: Install LLVM and Clang + if: matrix.sys.compiler == 'clang' run: | - LLVM_VERSION=${{ matrix.sys.version }} - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1 - if [[ $LLVM_VERSION -ge 13 ]]; then - sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$LLVM_VERSION main" || exit 1 - else - sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" || exit 1 - fi || exit 1 - sudo apt-get update || exit 1 - sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION || exit 1 - sudo apt-get --no-install-suggests --no-install-recommends install g++-9 g++-9-multilib || exit 1 - sudo ln -s /usr/include/asm-generic /usr/include/asm - CC=clang-$LLVM_VERSION - echo "CC=$CC" >> $GITHUB_ENV - CXX=clang++-$LLVM_VERSION - echo "CXX=$CXX" >> $GITHUB_ENV + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{matrix.sys.version}} + sudo apt-get install -y clang-tools-${{matrix.sys.version}} + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{matrix.sys.version}} 200 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{matrix.sys.version}} 200 + sudo update-alternatives --install /usr/bin/clang-scan-deps clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} 200 + sudo update-alternatives --set clang /usr/bin/clang-${{matrix.sys.version}} + sudo update-alternatives --set clang++ /usr/bin/clang++-${{matrix.sys.version}} + sudo update-alternatives --set clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v6 - name: Set conda environment uses: mamba-org/setup-micromamba@main @@ -73,10 +85,9 @@ jobs: ${{ (matrix.sys.name == 'tbb' || matrix.sys.name == 'xsimd-tbb' ) && 'tbb-devel' || '' }} - name: Configure using CMake - # env: - # CC: ${{ env.CC }} - # CXX: ${{ env.CXX }} - run: cmake -G Ninja -Bbuild -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON ${{ matrix.sys.flags }} + run: | + if [[ "${{matrix.sys.compiler}}" = "gcc" ]]; then export CC=gcc-${{matrix.sys.version}}; export CXX=g++-${{matrix.sys.version}}; else export CC=clang; export CXX=clang++; fi + cmake -G Ninja -Bbuild -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON ${{ matrix.sys.flags }} - name: Install working-directory: build @@ -84,7 +95,7 @@ jobs: - name: Build working-directory: build - run: cmake --build . --target test_xtensor_lib --parallel 8 + run: cmake --build . --target test_xtensor_lib - name: Run tests working-directory: build diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml index 55b3f816c..5dbce477e 100644 --- a/.github/workflows/osx.yml +++ b/.github/workflows/osx.yml @@ -18,13 +18,13 @@ jobs: fail-fast: false matrix: os: - - 11 - - 12 + - 14 + - 15 steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set conda environment uses: mamba-org/setup-micromamba@main diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml new file mode 100644 index 000000000..c008e832c --- /dev/null +++ b/.github/workflows/sanitizers.yml @@ -0,0 +1,110 @@ +name: Sanitizers +on: + workflow_dispatch: + pull_request: + push: + branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true +defaults: + run: + shell: bash -e -l {0} +jobs: + build: + runs-on: ${{ matrix.os }} + name: sanitizer / ${{ matrix.sys.compiler }} ${{ matrix.sys.version }} / ${{ matrix.config.name }} / ${{ matrix.sys.name }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-24.04] + sys: + - {compiler: clang, version: '21', name: asan, sanitizer: address} + - {compiler: clang, version: '21', name: lsan, sanitizer: leak} + - {compiler: clang, version: '21', name: ubsan, sanitizer: undefined} + config: + - {name: Debug} + + steps: + + - name: Install LLVM and Clang + if: matrix.sys.compiler == 'clang' + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{matrix.sys.version}} + sudo apt-get install -y clang-tools-${{matrix.sys.version}} + sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{matrix.sys.version}} 200 + sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{matrix.sys.version}} 200 + sudo update-alternatives --install /usr/bin/clang-scan-deps clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} 200 + sudo update-alternatives --set clang /usr/bin/clang-${{matrix.sys.version}} + sudo update-alternatives --set clang++ /usr/bin/clang++-${{matrix.sys.version}} + sudo update-alternatives --set clang-scan-deps /usr/bin/clang-scan-deps-${{matrix.sys.version}} + + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + + - name: Configure using CMake + run: | + export CC=clang + export CXX=clang++ + cmake -G Ninja \ + -Bbuild \ + -DCMAKE_BUILD_TYPE=${{matrix.config.name}} \ + -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX \ + -DBUILD_TESTS=ON \ + -DUSE_SANITIZER=${{ matrix.sys.sanitizer }} + + - name: Build tests + working-directory: build + run: cmake --build . --config ${{matrix.config.name}} --target test_xtensor_lib --parallel 8 + + - name: Run tests + working-directory: build + run: | + SAN=${{ matrix.sys.sanitizer }} + case "$SAN" in + address) + export ASAN_OPTIONS=log_path=asan_log_:alloc_dealloc_mismatch=0:halt_on_error=0:handle_abort=0 + export ASAN_SAVE_DUMPS=AsanDump.dmp + ;; + leak) + export LSAN_OPTIONS=log_path=lsan_log_:halt_on_error=0 + ;; + undefined) + export UBSAN_OPTIONS=log_path=ubsan_log_:halt_on_error=0:print_stacktrace=1 + ;; + esac + ctest -R ^xtest$ --output-on-failure + + - name: Upload sanitizer log + if: always() + uses: actions/upload-artifact@v6 + with: + name: sanitizer-log-${{ matrix.sys.sanitizer }}-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.config.name }}-${{ runner.os }} + path: '**/*san_log_*' + if-no-files-found: ignore + + - name: Upload sanitizer dump + if: always() + uses: actions/upload-artifact@v6 + with: + name: sanitizer-dump-${{ matrix.sys.sanitizer }}-${{ matrix.sys.compiler }}-${{ matrix.sys.version }}-${{ matrix.config.name }}-${{ runner.os }} + path: '**/AsanDump.dmp' + if-no-files-found: ignore + + - name: Return errors if sanitizer log content is not empty + if: always() + run: | + if [ -n "$(find build/test -name '*san_log_*' -type f -size +0 2>/dev/null)" ]; then + echo "Sanitizer detected errors. See the log for details." + exit 1 + fi diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 5441a3371..64fe21244 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -10,5 +10,13 @@ jobs: pre-commit: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: pre-commit/action@v3.0.0 + - uses: actions/checkout@v6 + - uses: pre-commit/action@v3.0.1 + + include-check: + runs-on: ubuntu-latest + name: Check unused standard includes + steps: + - uses: actions/checkout@v6 + - run: pip install diskarzhan + - run: diskarzhan `find include -name '*.hpp'` diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 133e6c7c5..c04adc626 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -20,7 +20,8 @@ jobs: runs-on: [windows-latest] sys: - {compiler: default} - - {compiler: clang} + # Enable again and fix remaining issues after refactoring + #- {compiler: clang} steps: @@ -35,7 +36,7 @@ jobs: echo "CXX=clang++" >> $GITHUB_ENV - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set conda environment uses: mamba-org/setup-micromamba@main @@ -43,7 +44,7 @@ jobs: environment-name: myenv environment-file: environment-dev.yml init-shell: bash - cache-downloads: true + cache-downloads: false create-args: | ninja diff --git a/.gitignore b/.gitignore index 80fa14348..4a5bcec30 100644 --- a/.gitignore +++ b/.gitignore @@ -62,3 +62,7 @@ __pycache__ # Generated files *.pc +.vscode/settings.json + +# Allow tag JSONs under etc/xeus-cpp +!etc/xeus-cpp/tags.d/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d67461681..bfc98b9cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,12 +24,13 @@ repos: - id: remove-tabs args: [--whitespaces-count, '4'] - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - rev: v2.11.0 + rev: v2.16.0 hooks: - id: pretty-format-yaml args: [--autofix, --indent, '2'] types: [file] files: \.(yaml|yml|clang-format) + additional_dependencies: [setuptools] - repo: https://github.com/tdegeus/cpp_comment_format rev: v0.2.1 hooks: diff --git a/CMakeLists.txt b/CMakeLists.txt index 92c886dfc..331fb48c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,15 +7,26 @@ # The full license is in the file LICENSE, distributed with this software. # ############################################################################ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.15..3.29) project(xtensor CXX) set(XTENSOR_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +# xtensor tag files +set(XTENSOR_DATA_DIR "share/xeus-cpp") +set(XTENSOR_TAGFILES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/share/xeus-cpp/tagfiles) + +set(XTENSOR_CONF_DIR "etc/xeus-cpp") +set(XTENSOR_TAGCONFS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/etc/xeus-cpp/tags.d) + +file(COPY "${XTENSOR_TAGFILES_DIR}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/share/xeus-cpp") +file(COPY "${XTENSOR_TAGCONFS_DIR}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/etc/xeus-cpp") + + # Versionning # =========== -file(STRINGS "${XTENSOR_INCLUDE_DIR}/xtensor/xtensor_config.hpp" xtensor_version_defines +file(STRINGS "${XTENSOR_INCLUDE_DIR}/xtensor/core/xtensor_config.hpp" xtensor_version_defines REGEX "#define XTENSOR_VERSION_(MAJOR|MINOR|PATCH)") foreach(ver ${xtensor_version_defines}) if(ver MATCHES "#define XTENSOR_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$") @@ -29,7 +40,7 @@ message(STATUS "Building xtensor v${${PROJECT_NAME}_VERSION}") # Dependencies # ============ -set(xtl_REQUIRED_VERSION 0.7.5) +set(xtl_REQUIRED_VERSION 0.8.0) if(TARGET xtl) set(xtl_VERSION ${XTL_VERSION_MAJOR}.${XTL_VERSION_MINOR}.${XTL_VERSION_PATCH}) # Note: This is not SEMVER compatible comparison @@ -59,7 +70,7 @@ if(XTENSOR_USE_TBB AND XTENSOR_USE_OPENMP) endif() if(XTENSOR_USE_XSIMD) - set(xsimd_REQUIRED_VERSION 11.0.0) + set(xsimd_REQUIRED_VERSION 14.2.0) if(TARGET xsimd) set(xsimd_VERSION ${XSIMD_VERSION_MAJOR}.${XSIMD_VERSION_MINOR}.${XSIMD_VERSION_PATCH}) # Note: This is not SEMVER compatible comparison @@ -113,100 +124,100 @@ endif() # ===== set(XTENSOR_HEADERS - ${XTENSOR_INCLUDE_DIR}/xtensor/xaccessible.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xaccumulator.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xadapt.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xarray.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xassign.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xaxis_iterator.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xaxis_slice_iterator.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xblockwise_reducer.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xblockwise_reducer_functors.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xbroadcast.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xbuffer_adaptor.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xbuilder.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xchunked_array.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xchunked_assign.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xchunked_view.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xcomplex.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xcontainer.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xcsv.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xdynamic_view.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xeval.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xexception.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xexpression.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xexpression_holder.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xexpression_traits.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xfixed.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xfunction.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xfunctor_view.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xgenerator.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xhistogram.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xindex_view.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xinfo.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xio.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xiterable.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xiterator.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xjson.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xlayout.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xmanipulation.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xmasked_view.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xmath.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xmime.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xmultiindex_iterator.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xnoalias.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xnorm.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xnpy.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xoffset_view.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xoperation.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xoptional.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xoptional_assembly.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xoptional_assembly_base.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xoptional_assembly_storage.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xpad.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xrandom.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xreducer.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xrepeat.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xscalar.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xsemantic.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xset_operation.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xshape.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xslice.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xsort.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xstorage.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xstrided_view.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xstrided_view_base.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xstrides.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xtensor.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xtensor_config.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xtensor_forward.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xtensor_simd.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xutils.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xvectorize.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xview.hpp - ${XTENSOR_INCLUDE_DIR}/xtensor/xview_utils.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/chunk/xchunked_array.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/chunk/xchunked_assign.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/chunk/xchunked_view.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xadapt.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xarray.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xbuffer_adaptor.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xcontainer.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xfixed.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xscalar.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xstorage.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/containers/xtensor.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xaccessible.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xassign.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xeval.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xexpression.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xexpression_traits.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xfunction.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xiterable.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xiterator.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xlayout.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xmath.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xmultiindex_iterator.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xnoalias.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xoperation.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xsemantic.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xshape.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xstrides.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xtensor_config.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xtensor_forward.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/core/xvectorize.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/generators/xbuilder.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/generators/xgenerator.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/generators/xrandom.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/io/xcsv.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/io/xinfo.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/io/xio.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/io/xjson.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/io/xmime.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/io/xnpy.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xcomplex.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xexpression_holder.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xfft.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xhistogram.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xmanipulation.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xpad.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xset_operation.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/misc/xsort.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/optional/xoptional.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/optional/xoptional_assembly.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/optional/xoptional_assembly_base.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/optional/xoptional_assembly_storage.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/reducers/xaccumulator.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/reducers/xblockwise_reducer.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/reducers/xblockwise_reducer_functors.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/reducers/xnorm.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/reducers/xreducer.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/utils/xexception.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/utils/xtensor_simd.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/utils/xutils.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xaxis_iterator.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xaxis_slice_iterator.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xbroadcast.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xdynamic_view.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xfunctor_view.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xindex_view.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xmasked_view.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xoffset_view.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xrepeat.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xslice.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xstrided_view.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xstrided_view_base.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xview.hpp + ${XTENSOR_INCLUDE_DIR}/xtensor/views/xview_utils.hpp ) add_library(xtensor INTERFACE) target_include_directories(xtensor INTERFACE $ + $ $) -target_compile_features(xtensor INTERFACE cxx_std_14) +target_compile_features(xtensor INTERFACE cxx_std_20) target_link_libraries(xtensor INTERFACE xtl) OPTION(XTENSOR_ENABLE_ASSERT "xtensor bound check" OFF) OPTION(XTENSOR_CHECK_DIMENSION "xtensor dimension check" OFF) +OPTION(XTENSOR_FORCE_TEMPORARY_MEMORY_IN_ASSIGNMENTS "xtensor force the use of temporary memory when assigning instead of an automatic overlap check" ON) OPTION(BUILD_TESTS "xtensor test suite" OFF) OPTION(BUILD_BENCHMARK "xtensor benchmark" OFF) -OPTION(DOWNLOAD_GTEST "build gtest from downloaded sources" OFF) OPTION(DOWNLOAD_GBENCHMARK "download google benchmark and build from source" ON) OPTION(DEFAULT_COLUMN_MAJOR "set default layout to column major" OFF) -OPTION(DISABLE_VS2017 "disables the compilation of some test with Visual Studio 2017" OFF) -OPTION(CPP17 "enables C++17" OFF) -OPTION(CPP20 "enables C++20 (experimental)" OFF) +OPTION(CPP23 "enables C++23 (experimental)" OFF) OPTION(XTENSOR_DISABLE_EXCEPTIONS "Disable C++ exceptions" OFF) OPTION(DISABLE_MSVC_ITERATOR_CHECK "Disable the MVSC iterator check" ON) @@ -219,12 +230,12 @@ if(XTENSOR_CHECK_DIMENSION) add_definitions(-DXTENSOR_ENABLE_CHECK_DIMENSION) endif() -if(DEFAULT_COLUMN_MAJOR) - add_definitions(-DXTENSOR_DEFAULT_LAYOUT=layout_type::column_major) +if(XTENSOR_FORCE_TEMPORARY_MEMORY_IN_ASSIGNMENTS) + add_definitions(-DXTENSOR_FORCE_TEMPORARY_MEMORY_IN_ASSIGNMENTS) endif() -if(DISABLE_VS2017) - add_definitions(-DDISABLE_VS2017) +if(DEFAULT_COLUMN_MAJOR) + add_definitions(-DXTENSOR_DEFAULT_LAYOUT=layout_type::column_major) endif() if(MSVC AND DISABLE_MSVC_ITERATOR_CHECK) @@ -258,8 +269,8 @@ install(TARGETS xtensor export(EXPORT ${PROJECT_NAME}-targets FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake") -install(FILES ${XTENSOR_HEADERS} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/xtensor) +install(DIRECTORY ${XTENSOR_INCLUDE_DIR}/xtensor + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) set(XTENSOR_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}" CACHE STRING "install path for xtensorConfig.cmake") @@ -290,6 +301,12 @@ configure_file(${PROJECT_NAME}.pc.in install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig/") +install(DIRECTORY ${XTENSOR_TAGFILES_DIR} + DESTINATION ${XTENSOR_DATA_DIR}) + +install(DIRECTORY ${XTENSOR_TAGCONFS_DIR} + DESTINATION ${XTENSOR_CONF_DIR}) + # Write single include # ==================== @@ -312,17 +329,17 @@ endfunction() set(XTENSOR_SINGLE_INCLUDE ${XTENSOR_HEADERS}) string(REPLACE "${XTENSOR_INCLUDE_DIR}/" "" XTENSOR_SINGLE_INCLUDE "${XTENSOR_SINGLE_INCLUDE}") list(REMOVE_ITEM XTENSOR_SINGLE_INCLUDE - xtensor/xexpression_holder.hpp - xtensor/xjson.hpp - xtensor/xmime.hpp - xtensor/xnpy.hpp) + xtensor/misc/xexpression_holder.hpp + xtensor/io/xjson.hpp + xtensor/io/xmime.hpp + xtensor/io/xnpy.hpp) PREPEND(XTENSOR_SINGLE_INCLUDE "#include <" ${XTENSOR_SINGLE_INCLUDE}) POSTFIX(XTENSOR_SINGLE_INCLUDE ">" ${XTENSOR_SINGLE_INCLUDE}) string(REPLACE ";" "\n" XTENSOR_SINGLE_INCLUDE "${XTENSOR_SINGLE_INCLUDE}") string(CONCAT XTENSOR_SINGLE_INCLUDE "#ifndef XTENSOR\n" "#define XTENSOR\n\n" "${XTENSOR_SINGLE_INCLUDE}" "\n\n#endif\n") -file(WRITE "${CMAKE_BINARY_DIR}/xtensor.hpp" "${XTENSOR_SINGLE_INCLUDE}") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/xtensor.hpp" "${XTENSOR_SINGLE_INCLUDE}") -install(FILES "${CMAKE_BINARY_DIR}/xtensor.hpp" +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/xtensor.hpp" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/README.md b/README.md index c98905996..19c5f9fe1 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,13 @@ # ![xtensor](docs/source/xtensor.svg) -[![GithubActions](https://github.com/xtensor-stack/xtensor/actions/workflows/ci.yml/badge.svg)](https://github.com/xtensor-stack/xtensor/actions/workflows/ci.yml) +[![GHA Linux](https://github.com/xtensor-stack/xtensor/actions/workflows/linux.yml/badge.svg)](https://github.com/xtensor-stack/xtensor/actions/workflows/linux.yml) +[![GHA OSX](https://github.com/xtensor-stack/xtensor/actions/workflows/osx.yml/badge.svg)](https://github.com/xtensor-stack/xtensor/actions/workflows/osx.yml) +[![GHA Windows](https://github.com/xtensor-stack/xtensor/actions/workflows/windows.yml/badge.svg)](https://github.com/xtensor-stack/xtensor/actions/workflows/windows.yml) [![Documentation](http://readthedocs.org/projects/xtensor/badge/?version=latest)](https://xtensor.readthedocs.io/en/latest/?badge=latest) [![Doxygen -> gh-pages](https://github.com/xtensor-stack/xtensor/workflows/gh-pages/badge.svg)](https://xtensor-stack.github.io/xtensor) [![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/xtensor-stack/xtensor/stable?filepath=notebooks%2Fxtensor.ipynb) -[![Join the Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/QuantStack/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Zulip](https://img.shields.io/badge/social_chat-zulip-blue.svg)](https://xtensor.zulipchat.com/#narrow/channel/539553-Ask-anything) +[![CodSpeed](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/xtensor-stack/xtensor?utm_source=badge) Multi-dimensional arrays with broadcasting and lazy computing. @@ -30,11 +33,10 @@ Julia and R bindings, check out the [xtensor-python](https://github.com/xtensor- [xtensor-julia](https://github.com/xtensor-stack/Xtensor.jl) and [xtensor-r](https://github.com/xtensor-stack/xtensor-r) projects respectively. -`xtensor` requires a modern C++ compiler supporting C++14. The following C++ -compilers are supported: +Up to version 0.26.0, `xtensor` requires a C++ compiler supporting C++14. +`xtensor` 0.26.x requires a C++ compiler supporting C++17. +`xtensor` 0.27.x requires a C++ compiler supporting C++20. - - On Windows platforms, Visual C++ 2015 Update 2, or more recent - - On Unix platforms, gcc 4.9 or a recent version of Clang ## Installation @@ -95,7 +97,11 @@ library: | `xtensor` | `xtl` |`xsimd` (optional) | |-----------|---------|-------------------| -| master | ^0.7.5 | ^10.0.0 | +| master | ^0.8.0 | ^13.2.0 | +| 0.27.1 | ^0.8.0 | ^13.2.0 | +| 0.27.0 | ^0.8.0 | ^13.2.0 | +| 0.26.0 | ^0.8.0 | ^13.2.0 | +| 0.25.0 | ^0.7.5 | ^11.0.0 | | 0.24.7 | ^0.7.0 | ^10.0.0 | | 0.24.6 | ^0.7.0 | ^10.0.0 | | 0.24.5 | ^0.7.0 | ^10.0.0 | diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index c5fa3c407..0d0ce5766 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -6,7 +6,8 @@ # The full license is in the file LICENSE, distributed with this software. # ############################################################################ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.22) +include(FetchContent) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) project(xtensor-benchmark) @@ -15,26 +16,35 @@ if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) set(XTENSOR_INCLUDE_DIR ${xtensor_INCLUDE_DIRS}) endif () -message(STATUS "Forcing tests build type to Release") -set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) +if(CODSPEED_MODE AND NOT CODSPEED_MODE STREQUAL "off") + message(STATUS "CodSpeed mode enabled (${CODSPEED_MODE}) - using RelWithDebInfo build type") + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE) +else() + message(STATUS "Forcing tests build type to Release") + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) +endif() include(CheckCXXCompilerFlag) string(TOUPPER "${CMAKE_BUILD_TYPE}" U_CMAKE_BUILD_TYPE) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") - CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported) - if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") + # Skip -march=native for CodSpeed simulation mode (valgrind does not + # support all native instruction sets) + if(NOT (CODSPEED_MODE STREQUAL "simulation")) + CHECK_CXX_COMPILER_FLAG(-march=native arch_native_supported) + if(arch_native_supported AND NOT CMAKE_CXX_FLAGS MATCHES "-march") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") + endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -g -Wunused-parameter -Wextra -Wreorder") if(NOT "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) - if (HAS_CPP14_FLAG) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") + CHECK_CXX_COMPILER_FLAG("-std=c++20" HAS_CPP20_FLAG) + if (HAS_CPP20_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20") else() - message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++14 support!") + message(FATAL_ERROR "Unsupported compiler -- xtensor requires C++17 support!") endif() endif() @@ -74,32 +84,19 @@ endif() if(DOWNLOAD_GBENCHMARK OR GBENCHMARK_SRC_DIR) - if(DOWNLOAD_GBENCHMARK) - # Download and unpack googlebenchmark at configure time - configure_file(downloadGBenchmark.cmake.in googlebenchmark-download/CMakeLists.txt) - else() - # Copy local source of googlebenchmark at configure time - configure_file(copyGBenchmark.cmake.in googlebenchmark-download/CMakeLists.txt) - endif() - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-download ) - if(result) - message(FATAL_ERROR "CMake step for googlebenchmark failed: ${result}") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-download ) - if(result) - message(FATAL_ERROR "Build step for googlebenchmark failed: ${result}") - endif() - - # Add googlebenchmark directly to our build. This defines - # the gtest and gtest_main targets. - add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-src - ${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-build) - - set(GBENCHMARK_INCLUDE_DIRS "${googlebenchmark_SOURCE_DIR}/include") + FetchContent_Declare(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG main) + + FetchContent_Declare(googlebenchmark + GIT_REPOSITORY https://github.com/CodSpeedHQ/codspeed-cpp.git + GIT_TAG main + SOURCE_SUBDIR google_benchmark) + + FetchContent_MakeAvailable( + googletest + googlebenchmark) + set(GBENCHMARK_INCLUDE_DIRS "${googlebenchmark_SOURCE_DIR}/google_benchmark/include") set(GBENCHMARK_LIBRARIES benchmark) else() find_package(benchmark REQUIRED) @@ -129,9 +126,11 @@ set(XTENSOR_BENCHMARK benchmark_view_access.cpp benchmark_view_assignment.cpp benchmark_view_adapt.cpp + benchmark_stl.cpp main.cpp ) + set(XTENSOR_BENCHMARK_TARGET benchmark_xtensor) add_executable(${XTENSOR_BENCHMARK_TARGET} EXCLUDE_FROM_ALL ${XTENSOR_BENCHMARK} ${XTENSOR_HEADERS}) target_link_libraries(${XTENSOR_BENCHMARK_TARGET} PUBLIC xtensor ${GBENCHMARK_LIBRARIES}) diff --git a/benchmark/benchmark_adapter.cpp b/benchmark/benchmark_adapter.cpp index c1f6f19c5..3a76dcb7e 100644 --- a/benchmark/benchmark_adapter.cpp +++ b/benchmark/benchmark_adapter.cpp @@ -8,11 +8,11 @@ #include -// #include "xtensor/xshape.hpp" -#include "xtensor/xadapt.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xstorage.hpp" -#include "xtensor/xutils.hpp" +// #include "xtensor/core/core/xshape.hpp" +#include "xtensor/containers/xadapt.hpp" +#include "xtensor/containers/xstorage.hpp" +#include "xtensor/core/xnoalias.hpp" +#include "xtensor/utils/xutils.hpp" namespace xt { diff --git a/benchmark/benchmark_assign.cpp b/benchmark/benchmark_assign.cpp index 9f44a7458..b9efb341e 100644 --- a/benchmark/benchmark_assign.cpp +++ b/benchmark/benchmark_assign.cpp @@ -11,9 +11,9 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xnoalias.hpp" namespace xt { diff --git a/benchmark/benchmark_builder.cpp b/benchmark/benchmark_builder.cpp index 1b49d0d59..e25de39cb 100644 --- a/benchmark/benchmark_builder.cpp +++ b/benchmark/benchmark_builder.cpp @@ -8,9 +8,9 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xnoalias.hpp" namespace xt { diff --git a/benchmark/benchmark_container.cpp b/benchmark/benchmark_container.cpp index 2b85e279a..af51d1d19 100644 --- a/benchmark/benchmark_container.cpp +++ b/benchmark/benchmark_container.cpp @@ -12,8 +12,8 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" namespace xt { diff --git a/benchmark/benchmark_creation.cpp b/benchmark/benchmark_creation.cpp index 0e4b0a18e..4410d2325 100644 --- a/benchmark/benchmark_creation.cpp +++ b/benchmark/benchmark_creation.cpp @@ -8,10 +8,10 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xbuilder.hpp" -#include "xtensor/xfixed.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xfixed.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/generators/xbuilder.hpp" namespace xt { diff --git a/benchmark/benchmark_increment_stepper.cpp b/benchmark/benchmark_increment_stepper.cpp index cc0256fd9..1557692e2 100644 --- a/benchmark/benchmark_increment_stepper.cpp +++ b/benchmark/benchmark_increment_stepper.cpp @@ -8,8 +8,8 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xrandom.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/generators/xrandom.hpp" #define SHAPE 30, 30 #define RANGE 3, 100 diff --git a/benchmark/benchmark_lambda_expressions.cpp b/benchmark/benchmark_lambda_expressions.cpp index 3d9ff8cf3..6c6c40a49 100644 --- a/benchmark/benchmark_lambda_expressions.cpp +++ b/benchmark/benchmark_lambda_expressions.cpp @@ -8,11 +8,11 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xbuilder.hpp" -#include "xtensor/xmath.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xmath.hpp" +#include "xtensor/core/xnoalias.hpp" +#include "xtensor/generators/xbuilder.hpp" namespace xt { diff --git a/benchmark/benchmark_math.cpp b/benchmark/benchmark_math.cpp index 20fd0c726..c365551ea 100644 --- a/benchmark/benchmark_math.cpp +++ b/benchmark/benchmark_math.cpp @@ -13,9 +13,9 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xnoalias.hpp" // For how many sizes should math functions be tested? #define MATH_RANGE 64, 64 diff --git a/benchmark/benchmark_random.cpp b/benchmark/benchmark_random.cpp index 82e87104a..e5279988d 100644 --- a/benchmark/benchmark_random.cpp +++ b/benchmark/benchmark_random.cpp @@ -11,10 +11,10 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xrandom.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xnoalias.hpp" +#include "xtensor/generators/xrandom.hpp" namespace xt { diff --git a/benchmark/benchmark_reducer.cpp b/benchmark/benchmark_reducer.cpp index fe36a850f..c4304782f 100644 --- a/benchmark/benchmark_reducer.cpp +++ b/benchmark/benchmark_reducer.cpp @@ -8,8 +8,8 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xreducer.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/reducers/xreducer.hpp" namespace xt { diff --git a/benchmark/benchmark_stl.cpp b/benchmark/benchmark_stl.cpp new file mode 100644 index 000000000..9ae160712 --- /dev/null +++ b/benchmark/benchmark_stl.cpp @@ -0,0 +1,157 @@ +/*************************************************************************** + * Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht * + * * + * Distributed under the terms of the BSD 3-Clause License. * + * * + * The full license is in the file LICENSE, distributed with this software. * + ****************************************************************************/ + +#include + +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xmath.hpp" +#include "xtensor/generators/xrandom.hpp" + +namespace xt +{ + namespace + { + constexpr std::array cContainerAssignShape{2000, 2000}; + + template + auto generateRandomInt16From0To100(Shape&& x) + { + return xt::random::randint(x, 0, 100); + } + } + + static void Xtensor_Uint16_2000x2000_DivideBy2_StdTransform(benchmark::State& aState) + { + xt::xtensor vInput = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + std::transform( + vInput.begin(), + vInput.end(), + vOutput.begin(), + [](auto&& aInputValue) + { + return aInputValue / 2; + } + ); + } + } + + static void Xtensor_Uint16_2000x2000_DivideBy2_Xtensor(benchmark::State& aState) + { + xt::xtensor vInput = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + vOutput = vInput / 2; + } + } + + static void Xtensor_Uint16_2000x2000_DivideBy2Double_StdTransform(benchmark::State& aState) + { + xt::xtensor vInput = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + std::transform( + vInput.begin(), + vInput.end(), + vOutput.begin(), + [](auto&& aInputValue) + { + return aInputValue / 2.0; + } + ); + } + } + + static void Xtensor_Uint16_2000x2000_DivideBy2Double_Xtensor(benchmark::State& aState) + { + xt::xtensor vInput = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + vOutput = vInput / 2.0; + } + } + + static void Xtensor_Uint16_2000x2000_MultiplyBy2_StdTransform(benchmark::State& aState) + { + xt::xtensor vInput = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + std::transform( + vInput.begin(), + vInput.end(), + vOutput.begin(), + [](auto&& aInputValue) + { + return aInputValue * 2; + } + ); + } + } + + static void Xtensor_Uint16_2000x2000_MultiplyBy2_Xtensor(benchmark::State& aState) + { + xt::xtensor vInput = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + vOutput = vInput * 2; + } + } + + static void Xtensor_Uint16_2000x2000_Maximum_StdTransform(benchmark::State& aState) + { + xt::xtensor vInput1 = generateRandomInt16From0To100(cContainerAssignShape); + xt::xtensor vInput2 = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + auto vInput2It = vInput2.begin(); + std::transform( + vInput1.begin(), + vInput1.end(), + vOutput.begin(), + [&vInput2It](auto&& aInput1Value) + { + return std::max(aInput1Value, *vInput2It++); + } + ); + } + } + + static void Xtensor_Uint16_2000x2000_Maximum_Xtensor(benchmark::State& aState) + { + xt::xtensor vInput1 = generateRandomInt16From0To100(cContainerAssignShape); + xt::xtensor vInput2 = generateRandomInt16From0To100(cContainerAssignShape); + auto vOutput = xt::xtensor::from_shape(cContainerAssignShape); + + for (auto _ : aState) + { + vOutput = xt::maximum(vInput1, vInput2); + } + } + + BENCHMARK(Xtensor_Uint16_2000x2000_Maximum_Xtensor); + BENCHMARK(Xtensor_Uint16_2000x2000_Maximum_StdTransform); + BENCHMARK(Xtensor_Uint16_2000x2000_MultiplyBy2_Xtensor); + BENCHMARK(Xtensor_Uint16_2000x2000_MultiplyBy2_StdTransform); + BENCHMARK(Xtensor_Uint16_2000x2000_DivideBy2Double_Xtensor); + BENCHMARK(Xtensor_Uint16_2000x2000_DivideBy2Double_StdTransform); +} diff --git a/benchmark/benchmark_view_access.cpp b/benchmark/benchmark_view_access.cpp index 7fdb4d0a8..78569955e 100644 --- a/benchmark/benchmark_view_access.cpp +++ b/benchmark/benchmark_view_access.cpp @@ -8,14 +8,14 @@ #include -// #include "xtensor/xshape.hpp" -#include "xtensor/xadapt.hpp" -#include "xtensor/xbuilder.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xrandom.hpp" -#include "xtensor/xstorage.hpp" -#include "xtensor/xutils.hpp" -#include "xtensor/xview.hpp" +// #include "xtensor/core/core/xshape.hpp" +#include "xtensor/containers/xadapt.hpp" +#include "xtensor/containers/xstorage.hpp" +#include "xtensor/core/xnoalias.hpp" +#include "xtensor/generators/xbuilder.hpp" +#include "xtensor/generators/xrandom.hpp" +#include "xtensor/utils/xutils.hpp" +#include "xtensor/views/xview.hpp" namespace xt { diff --git a/benchmark/benchmark_view_adapt.cpp b/benchmark/benchmark_view_adapt.cpp index e5059f7b3..2523cb725 100644 --- a/benchmark/benchmark_view_adapt.cpp +++ b/benchmark/benchmark_view_adapt.cpp @@ -11,12 +11,12 @@ #include -#include "xtensor/xadapt.hpp" -#include "xtensor/xfixed.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xrandom.hpp" -#include "xtensor/xtensor.hpp" -#include "xtensor/xview.hpp" +#include "xtensor/containers/xadapt.hpp" +#include "xtensor/containers/xfixed.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xnoalias.hpp" +#include "xtensor/generators/xrandom.hpp" +#include "xtensor/views/xview.hpp" namespace xt { diff --git a/benchmark/benchmark_view_assignment.cpp b/benchmark/benchmark_view_assignment.cpp index 2bfd5f5cf..3d5ae314b 100644 --- a/benchmark/benchmark_view_assignment.cpp +++ b/benchmark/benchmark_view_assignment.cpp @@ -8,11 +8,11 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xfixed.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xrandom.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xfixed.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xnoalias.hpp" +#include "xtensor/generators/xrandom.hpp" namespace xt { @@ -61,23 +61,24 @@ namespace xt } } - inline void assign_create_strided_view(benchmark::State& state) - { - xt::xtensor tens = xt::random::rand({100, 100, 3, 3}); - for (auto _ : state) - { - for (std::size_t i = 0; i < tens.shape()[0]; ++i) - { - for (std::size_t j = 0; j < tens.shape()[1]; ++j) - { - auto v = xt::strided_view(tens, {i, j, all(), all()}); - xt::xtensor vas = v; - benchmark::ClobberMemory(); - } - } - } - } - + /** + * inline void assign_create_strided_view(benchmark::State& state) + * { + * xt::xtensor tens = xt::random::rand({100, 100, 3, 3}); + * for (auto _ : state) + * { + * for (std::size_t i = 0; i < tens.shape()[0]; ++i) + * { + * for (std::size_t j = 0; j < tens.shape()[1]; ++j) + * { + * auto v = xt::strided_view(tens, {i, j, all(), all()}); + * xt::xtensor vas = v; + * benchmark::ClobberMemory(); + * } + * } + * } + * } + */ inline void assign_create_manual_view(benchmark::State& state) { xt::xtensor tens = xt::random::rand({100, 100, 3, 3}); @@ -151,9 +152,9 @@ namespace xt BENCHMARK(create_strided_view_outofplace); BENCHMARK(create_strided_view_inplace); BENCHMARK(assign_create_manual_noview); - BENCHMARK(assign_create_strided_view); + // BENCHMARK(assign_create_strided_view); BENCHMARK(assign_create_view); BENCHMARK(assign_create_manual_view); - BENCHMARK(data_offset); + // BENCHMARK(data_offset); BENCHMARK(data_offset_view); } diff --git a/benchmark/benchmark_views.cpp b/benchmark/benchmark_views.cpp index db233ec05..f2c34d510 100644 --- a/benchmark/benchmark_views.cpp +++ b/benchmark/benchmark_views.cpp @@ -12,13 +12,13 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xmanipulation.hpp" -#include "xtensor/xnoalias.hpp" -#include "xtensor/xstrided_view.hpp" -#include "xtensor/xstrides.hpp" -#include "xtensor/xtensor.hpp" -#include "xtensor/xview.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" +#include "xtensor/core/xnoalias.hpp" +#include "xtensor/core/xstrides.hpp" +#include "xtensor/misc/xmanipulation.hpp" +#include "xtensor/views/xstrided_view.hpp" +#include "xtensor/views/xview.hpp" namespace xt { diff --git a/benchmark/benchmark_xshape.cpp b/benchmark/benchmark_xshape.cpp index 9b6a8e6dd..6656b912f 100644 --- a/benchmark/benchmark_xshape.cpp +++ b/benchmark/benchmark_xshape.cpp @@ -12,8 +12,8 @@ #include -#include "xtensor/xshape.hpp" -#include "xtensor/xstorage.hpp" +#include "xtensor/containers/xstorage.hpp" +#include "xtensor/core/xshape.hpp" namespace xt { diff --git a/benchmark/copyGBenchmark.cmake.in b/benchmark/copyGBenchmark.cmake.in index 753108438..e11eaed96 100644 --- a/benchmark/copyGBenchmark.cmake.in +++ b/benchmark/copyGBenchmark.cmake.in @@ -6,7 +6,7 @@ # The full license is in the file LICENSE, distributed with this software. # ############################################################################ -cmake_minimum_required(VERSION 2.8.2) +cmake_minimum_required(VERSION 3.5) project(googlebenchmark-download NONE) diff --git a/benchmark/downloadGBenchmark.cmake.in b/benchmark/downloadGBenchmark.cmake.in index eb8b2d029..7af348b1e 100644 --- a/benchmark/downloadGBenchmark.cmake.in +++ b/benchmark/downloadGBenchmark.cmake.in @@ -6,18 +6,19 @@ # The full license is in the file LICENSE, distributed with this software. # ############################################################################ -cmake_minimum_required(VERSION 2.8.2) +cmake_minimum_required(VERSION 3.5) project(googlebenchmark-download NONE) include(ExternalProject) ExternalProject_Add(googlebenchmark GIT_REPOSITORY https://github.com/google/benchmark.git - GIT_TAG v1.3.0 + GIT_TAG v1.9.4 SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-src" BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-build" CONFIGURE_COMMAND "" BUILD_COMMAND "" + CMAKE_ARGS "BENCHMARK_DOWNLOAD_DEPENDENCIES=TRUE" INSTALL_COMMAND "" TEST_COMMAND "" ) diff --git a/benchmark/main.cpp b/benchmark/main.cpp index 6444c0efb..39491c225 100644 --- a/benchmark/main.cpp +++ b/benchmark/main.cpp @@ -10,8 +10,8 @@ #include -#include "xtensor/xarray.hpp" -#include "xtensor/xtensor.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/containers/xtensor.hpp" #ifdef XTENSOR_USE_XSIMD #ifdef __GNUC__ diff --git a/cmake/sanitizers.cmake b/cmake/sanitizers.cmake new file mode 100644 index 000000000..11c7a1075 --- /dev/null +++ b/cmake/sanitizers.cmake @@ -0,0 +1,50 @@ +set(AVALAIBLE_SANITIZERS "address;leak;memory;thread;undefined") +OPTION(USE_SANITIZER "Enable sanitizer(s). Options are: ${AVALAIBLE_SANITIZERS}. Case insensitive; multiple options delimited by comma or space possible." "") +string(TOLOWER "${USE_SANITIZER}" USE_SANITIZER) + +if((CMAKE_BUILD_TYPE IN_LIST "Debug;RelWithDebInfo") AND USE_SANITIZER) + message(FATAL_ERROR "❌ Sanitizer only supported in Debug and RelWithDebInfo build types.") +endif() + +if(USE_SANITIZER) + if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$,$>,$<$:EditAndContinue>,$<$:ProgramDatabase>>") + + if(USE_SANITIZER MATCHES "address") + list(APPEND SANITIZER_COMPILE_OPTIONS /fsanitize=address /D_DISABLE_VECTOR_ANNOTATION /D_DISABLE_STRING_ANNOTATION) + else() + message(FATAL_ERROR "❌ Sanitizer not supported by MSVC: ${USE_SANITIZER}. It only supports 'address'.") + endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC") + if(USE_SANITIZER MATCHES "address") + list(APPEND SANITIZER_COMPILE_OPTIONS /fsanitize=address /D_DISABLE_VECTOR_ANNOTATION /D_DISABLE_STRING_ANNOTATION) + list(APPEND SANITIZER_LINK_LIBRARIES clang_rt.asan_dynamic-x86_64 clang_rt.asan_dynamic_runtime_thunk-x86_64) + else() + message(FATAL_ERROR "❌ Sanitizer not supported by Clang-MSVC: ${USE_SANITIZER}. It only supports 'address'.") + endif() + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + foreach(sanitizer ${USE_SANITIZER}) + if(NOT ${sanitizer} IN_LIST AVALAIBLE_SANITIZERS) + message(FATAL_ERROR "❌ Sanitizer not supported: ${sanitizer}. It should be one of: ${AVALAIBLE_SANITIZERS}.") + endif() + list(APPEND SANITIZER_COMPILE_OPTIONS -fsanitize=${sanitizer}) + list(APPEND SANITIZER_LINK_OPTIONS -fsanitize=${sanitizer}) + if (${sanitizer} MATCHES "undefined") + list(APPEND SANITIZER_COMPILE_OPTIONS -fno-sanitize=signed-integer-overflow) + endif() + if (${sanitizer} MATCHES "memory") + list(APPEND SANITIZER_LINK_LIBRARIES -fsanitize-memory-track-origins -fPIE -pie) + list(APPEND SANITIZER_LINK_OPTIONS -fsanitize-memory-track-origins -fPIE -pie) + endif() + endforeach() + list(APPEND SANITIZER_COMPILE_OPTIONS -fno-omit-frame-pointer) + else() + message(FATAL_ERROR "❌ Sanitizer: Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}") + endif() + + list(REMOVE_DUPLICATES SANITIZER_COMPILE_OPTIONS) + list(REMOVE_DUPLICATES SANITIZER_LINK_OPTIONS) + list(REMOVE_DUPLICATES SANITIZER_LINK_LIBRARIES) + + message(STATUS "🔍 Using sanitizer: ${USE_SANITIZER}") +endif() diff --git a/docs/source/adaptor.rst b/docs/source/adaptor.rst index c4bd153ac..64fd7caf3 100644 --- a/docs/source/adaptor.rst +++ b/docs/source/adaptor.rst @@ -20,8 +20,8 @@ The following example shows how to bring an ``std::vector`` into the expression #include #include - #include - #include + #include + #include std::vector v = {1., 2., 3., 4., 5., 6. }; std::vector shape = { 2, 3 }; @@ -50,7 +50,7 @@ ownership of the array: .. code:: #include - #include + #include void compute(double* data, std::size_t size) { @@ -82,8 +82,8 @@ the ownership of the array, meaning it will be deleted when the adaptor is destr .. code:: #include - #include - #include + #include + #include void compute(double*& data, std::size_t size) { @@ -119,8 +119,8 @@ adaptor before calling ``compute`` and pass it to the function: .. code:: #include - #include - #include + #include + #include template void compute(A& a) @@ -154,8 +154,8 @@ Adapting C arrays allocated on the stack is as simple as adapting ``std::vector` #include #include - #include - #include + #include + #include double v[6] = {1., 2., 3., 4., 5., 6. }; std::vector shape = { 2, 3 }; @@ -185,8 +185,8 @@ It will automatically increment the reference count of shared pointers upon crea .. code:: #include - #include - #include + #include + #include std::shared_ptr sptr(new double[8], std::default_delete()); sptr.get()[2] = 321.; @@ -201,8 +201,8 @@ memory) as follows: .. code:: #include - #include - #include + #include + #include struct Buffer { Buffer(std::vector& buf) : m_buf(buf) {} diff --git a/docs/source/api/accumulating_functions.rst b/docs/source/api/accumulating_functions.rst index 2bab12e94..1842912e1 100644 --- a/docs/source/api/accumulating_functions.rst +++ b/docs/source/api/accumulating_functions.rst @@ -9,12 +9,7 @@ Accumulating functions **xtensor** provides the following accumulating functions for xexpressions: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: cumsum(E&&) - -.. doxygenfunction:: cumsum(E&&, std::ptrdiff_t) - -.. doxygenfunction:: cumprod(E&&) - -.. doxygenfunction:: cumprod(E&&, std::ptrdiff_t) +.. doxygengroup:: acc_functions + :members: diff --git a/docs/source/api/basic_functions.rst b/docs/source/api/basic_functions.rst index 4cdd11450..c6e8020b8 100644 --- a/docs/source/api/basic_functions.rst +++ b/docs/source/api/basic_functions.rst @@ -9,28 +9,7 @@ Basic functions **xtensor** provides the following basic functions for xexpressions and scalars: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: abs(E&&) - -.. doxygenfunction:: fabs(E&&) - -.. doxygenfunction:: fmod(E1&&, E2&&) - -.. doxygenfunction:: remainder(E1&&, E2&&) - -.. doxygenfunction:: fma(E1&&, E2&&, E3&&) - -.. doxygenfunction:: maximum(E1&&, E2&&) - -.. doxygenfunction:: minimum(E1&&, E2&&) - -.. doxygenfunction:: fmax(E1&&, E2&&) - -.. doxygenfunction:: fmin(E1&&, E2&&) - -.. doxygenfunction:: fdim(E1&&, E2&&) - -.. doxygenfunction:: clip(E1&&, E2&&, E3&&) - -.. doxygenfunction:: sign(E&&) +.. doxygengroup:: basic_functions + :members: diff --git a/docs/source/api/classif_functions.rst b/docs/source/api/classif_functions.rst index aa7b8cc51..f39602b2b 100644 --- a/docs/source/api/classif_functions.rst +++ b/docs/source/api/classif_functions.rst @@ -9,14 +9,7 @@ Classification functions **xtensor** provides the following classification functions for xexpressions and scalars: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: isfinite(E&&) - -.. doxygenfunction:: isinf(E&&) - -.. doxygenfunction:: isnan(E&&) - -.. doxygenfunction:: isclose(E1&&, E2&&, double, double, bool) - -.. doxygenfunction:: allclose(E1&&, E2&, double, double) +.. doxygengroup:: classif_functions + :members: diff --git a/docs/source/api/container_index.rst b/docs/source/api/container_index.rst index bb3e2d724..ef8c0ba84 100644 --- a/docs/source/api/container_index.rst +++ b/docs/source/api/container_index.rst @@ -33,3 +33,4 @@ xexpression API is actually implemented in ``xstrided_container`` and ``xcontain xindex_view xfunctor_view xrepeat + xfft diff --git a/docs/source/api/error_functions.rst b/docs/source/api/error_functions.rst index aee5af61b..be2312f08 100644 --- a/docs/source/api/error_functions.rst +++ b/docs/source/api/error_functions.rst @@ -9,12 +9,7 @@ Error and gamma functions **xtensor** provides the following error and gamma functions for xexpressions: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: erf(E&&) - -.. doxygenfunction:: erfc(E&&) - -.. doxygenfunction:: tgamma(E&&) - -.. doxygenfunction:: lgamma(E&&) +.. doxygengroup:: err_functions + :members: diff --git a/docs/source/api/exponential_functions.rst b/docs/source/api/exponential_functions.rst index 4c2147a5a..65caeed74 100644 --- a/docs/source/api/exponential_functions.rst +++ b/docs/source/api/exponential_functions.rst @@ -9,18 +9,7 @@ Exponential functions **xtensor** provides the following exponential functions for xexpressions: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: exp(E&&) - -.. doxygenfunction:: exp2(E&&) - -.. doxygenfunction:: expm1(E&&) - -.. doxygenfunction:: log(E&&) - -.. doxygenfunction:: log2(E&&) - -.. doxygenfunction:: log10(E&&) - -.. doxygenfunction:: log1p(E&&) +.. doxygengroup:: exp_functions + :members: diff --git a/docs/source/api/hyperbolic_functions.rst b/docs/source/api/hyperbolic_functions.rst index f6b71958f..757c77409 100644 --- a/docs/source/api/hyperbolic_functions.rst +++ b/docs/source/api/hyperbolic_functions.rst @@ -9,22 +9,7 @@ Hyperbolic functions **xtensor** provides the following hyperbolic functions for xexpressions: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. _sinh-function-reference: -.. doxygenfunction:: sinh(E&&) - -.. _cosh-function-reference: -.. doxygenfunction:: cosh(E&&) - -.. _tanh-function-reference: -.. doxygenfunction:: tanh(E&&) - -.. _asinh-func-ref: -.. doxygenfunction:: asinh(E&&) - -.. _acosh-func-ref: -.. doxygenfunction:: acosh(E&&) - -.. _atanh-func-ref: -.. doxygenfunction:: atanh(E&&) +.. doxygengroup:: hyper_functions + :members: diff --git a/docs/source/api/index_related.rst b/docs/source/api/index_related.rst index c3f5b1ed7..f7de8fdc2 100644 --- a/docs/source/api/index_related.rst +++ b/docs/source/api/index_related.rst @@ -7,12 +7,9 @@ Index related functions ======================= -Defined in ``xtensor/xoperation.hpp`` +Defined in ``xtensor/core/xoperation.hpp`` -.. doxygenfunction:: where(const T&) +The logical operator group documents the index-producing overloads of +``xt::where``, ``xt::nonzero`` and ``xt::argwhere``. -.. doxygenfunction:: nonzero(const T&) - -.. doxygenfunction:: argwhere - -.. doxygenfunction:: from_indices +``xt::from_indices`` is documented on the ``xtensor`` API page. diff --git a/docs/source/api/nan_functions.rst b/docs/source/api/nan_functions.rst index 27f91d515..918039bce 100644 --- a/docs/source/api/nan_functions.rst +++ b/docs/source/api/nan_functions.rst @@ -9,28 +9,7 @@ NaN functions **xtensor** provides the following functions that deal with NaNs in xexpressions: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: nan_to_num(E&&) - -.. doxygenfunction:: nanmin(E&&, X&&, EVS) - -.. doxygenfunction:: nanmax(E&&, X&&, EVS) - -.. doxygenfunction:: nansum(E&&, X&&, EVS) - -.. doxygenfunction:: nanmean(E&&, X&&, EVS) - -.. doxygenfunction:: nanvar(E&&, X&&, EVS) - -.. doxygenfunction:: nanstd(E&&, X&&, EVS) - -.. doxygenfunction:: nanprod(E&&, X&&, EVS) - -.. doxygenfunction:: nancumsum(E&&) - -.. doxygenfunction:: nancumsum(E&&, std::ptrdiff_t) - -.. doxygenfunction:: nancumprod(E&&) - -.. doxygenfunction:: nancumprod(E&&, std::ptrdiff_t) +.. doxygengroup:: nan_functions + :members: diff --git a/docs/source/api/nearint_operations.rst b/docs/source/api/nearint_operations.rst index e083f8247..59dd61d19 100644 --- a/docs/source/api/nearint_operations.rst +++ b/docs/source/api/nearint_operations.rst @@ -9,16 +9,7 @@ Nearest integer floating point operations **xtensor** provides the following rounding operations for xexpressions: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: ceil(E&&) - -.. doxygenfunction:: floor(E&&) - -.. doxygenfunction:: trunc(E&&) - -.. doxygenfunction:: round(E&&) - -.. doxygenfunction:: nearbyint(E&&) - -.. doxygenfunction:: rint(E&&) +.. doxygengroup:: nearint_functions + :members: diff --git a/docs/source/api/operators.rst b/docs/source/api/operators.rst index 09128ceea..00df9458d 100644 --- a/docs/source/api/operators.rst +++ b/docs/source/api/operators.rst @@ -7,70 +7,19 @@ Operators and related functions =============================== -Defined in ``xtensor/xmath.hpp`` and ``xtensor/xoperation.hpp`` +Defined in ``xtensor/core/xmath.hpp`` and ``xtensor/core/xoperation.hpp`` -.. doxygenfunction:: operator+(E&&) +.. doxygengroup:: arithmetic_operators + :members: -.. doxygenfunction:: operator-(E&&) +.. doxygengroup:: logical_operators + :members: -.. doxygenfunction:: operator+(E1&&, E2&&) +.. doxygengroup:: comparison_operators + :members: -.. doxygenfunction:: operator-(E1&&, E2&&) +.. doxygengroup:: bitwise_operators + :members: -.. doxygenfunction:: operator*(E1&&, E2&&) - -.. doxygenfunction:: operator/(E1&&, E2&&) - -.. doxygenfunction:: operator||(E1&&, E2&&) - -.. doxygenfunction:: operator&&(E1&&, E2&&) - -.. doxygenfunction:: operator!(E&&) - -.. doxygenfunction:: where(E1&&, E2&&, E3&&) - -.. doxygenfunction:: any(E&&) - -.. doxygenfunction:: all(E&&) - -.. doxygenfunction:: operator<(E1&&, E2&&) - -.. doxygenfunction:: operator<=(E1&&, E2&&) - -.. doxygenfunction:: operator>(E1&&, E2&&) - -.. doxygenfunction:: operator>=(E1&&, E2&&) - -.. doxygenfunction:: operator==(const xexpression&, const xexpression&) - -.. doxygenfunction:: operator!=(const xexpression&, const xexpression&) - -.. doxygenfunction:: equal(E1&&, E2&&) - -.. doxygenfunction:: not_equal(E1&&, E2&&) - -.. doxygenfunction:: less(E1&& e1, E2&& e2) - -.. doxygenfunction:: less_equal(E1&& e1, E2&& e2) - -.. doxygenfunction:: greater(E1&& e1, E2&& e2) - -.. doxygenfunction:: greater_equal(E1&& e1, E2&& e2) - -.. doxygenfunction:: operator&(E1&&, E2&&) - -.. doxygenfunction:: operator|(E1&&, E2&&) - -.. doxygenfunction:: operator^(E1&&, E2&&) - -.. doxygenfunction:: operator~(E&&) - -.. doxygenfunction:: left_shift(E1&&, E2&&) - -.. doxygenfunction:: right_shift(E1&&, E2&&) - -.. doxygenfunction:: operator<<(E1&&, E2&&) - -.. doxygenfunction:: operator>>(E1&&, E2&&) - -.. doxygenfunction:: cast(E&&) +.. doxygengroup:: casting_operators + :members: diff --git a/docs/source/api/power_functions.rst b/docs/source/api/power_functions.rst index 5585bca5d..5ac5a1546 100644 --- a/docs/source/api/power_functions.rst +++ b/docs/source/api/power_functions.rst @@ -10,18 +10,7 @@ Power functions **xtensor** provides the following power functions for xexpressions and scalars: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: pow(E1&&, E2&&) - -.. doxygenfunction:: pow(E&&) - -.. doxygenfunction:: square(E1&&) - -.. doxygenfunction:: cube(E1&&) - -.. doxygenfunction:: sqrt(E&&) - -.. doxygenfunction:: cbrt(E&&) - -.. doxygenfunction:: hypot(E1&&, E2&&) +.. doxygengroup:: pow_functions + :members: diff --git a/docs/source/api/reducing_functions.rst b/docs/source/api/reducing_functions.rst index a8be2de61..89c0baff5 100644 --- a/docs/source/api/reducing_functions.rst +++ b/docs/source/api/reducing_functions.rst @@ -9,62 +9,7 @@ Reducing functions **xtensor** provides the following reducing functions for xexpressions: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` and ``xtensor/reducers/xnorm.hpp``. -.. doxygenfunction:: sum(E&&, EVS) - -.. doxygenfunction:: sum(E&&, X&&, EVS) - -.. doxygenfunction:: prod(E&&, EVS) - -.. doxygenfunction:: prod(E&&, X&&, EVS) - -.. doxygenfunction:: mean(E&&, EVS) - -.. doxygenfunction:: mean(E&&, X&&, EVS) - -.. doxygenfunction:: average(E&&, EVS) - -.. doxygenfunction:: variance(E&&, EVS) - -.. doxygenfunction:: variance(E&&, X&&, EVS) - -.. doxygenfunction:: variance(E&&, X&&, const D&, EVS) - -.. doxygenfunction:: stddev(E&&, EVS) - -.. doxygenfunction:: stddev(E&&, X&&, EVS) - -.. doxygenfunction:: diff(const xexpression&, unsigned int, std::ptrdiff_t) - -.. doxygenfunction:: amax(E&&, EVS) - -.. doxygenfunction:: amax(E&&, X&&, EVS) - -.. doxygenfunction:: amin(E&&, EVS) - -.. doxygenfunction:: amin(E&&, X&&, EVS) - -.. doxygenfunction:: trapz(const xexpression&, double, std::ptrdiff_t) - -.. doxygenfunction:: trapz(const xexpression&, const xexpression&, std::ptrdiff_t) - -Defined in ``xtensor/xnorm.hpp`` - -.. doxygenfunction:: norm_l0(E&&, X&&, EVS) - -.. doxygenfunction:: norm_l1(E&&, X&&, EVS) - -.. doxygenfunction:: norm_sq(E&&, X&&, EVS) - -.. doxygenfunction:: norm_l2(E&&, X&&, EVS) - -.. doxygenfunction:: norm_linf(E&&, X&&, EVS) - -.. doxygenfunction:: norm_lp_to_p(E&&, double, X&&, EVS) - -.. doxygenfunction:: norm_lp(E&&, double, X&&, EVS) - -.. doxygenfunction:: norm_induced_l1(E&&, EVS) - -.. doxygenfunction:: norm_induced_linf(E&&, EVS) +.. doxygengroup:: red_functions + :members: diff --git a/docs/source/api/trigonometric_functions.rst b/docs/source/api/trigonometric_functions.rst index 243bf57c5..e76d151b5 100644 --- a/docs/source/api/trigonometric_functions.rst +++ b/docs/source/api/trigonometric_functions.rst @@ -9,18 +9,7 @@ Trigonometric functions **xtensor** provides the following trigonometric functions for xexpressions and scalars: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` -.. doxygenfunction:: sin(E&&) - -.. doxygenfunction:: cos(E&&) - -.. doxygenfunction:: tan(E&&) - -.. doxygenfunction:: asin(E&&) - -.. doxygenfunction:: acos(E&&) - -.. doxygenfunction:: atan(E&&) - -.. doxygenfunction:: atan2(E1&&, E2&&) +.. doxygengroup:: trigo_functions + :members: diff --git a/docs/source/api/xaccessible.rst b/docs/source/api/xaccessible.rst new file mode 100644 index 000000000..237fc029d --- /dev/null +++ b/docs/source/api/xaccessible.rst @@ -0,0 +1,16 @@ +.. Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht + + Distributed under the terms of the BSD 3-Clause License. + + The full license is in the file LICENSE, distributed with this software. + +xaccessible +=========== + +Defined in ``xtensor/core/xaccessible.hpp`` + +.. doxygenclass:: xt::xconst_accessible + :members: + +.. doxygenclass:: xt::xaccessible + :members: diff --git a/docs/source/api/xaccumulator.rst b/docs/source/api/xaccumulator.rst index 07217167d..906f5288e 100644 --- a/docs/source/api/xaccumulator.rst +++ b/docs/source/api/xaccumulator.rst @@ -7,7 +7,7 @@ xaccumulator ============ -Defined in ``xtensor/xaccumulator.hpp`` +Defined in ``xtensor/reducers/xaccumulator.hpp`` .. doxygenfunction:: xt::accumulate(F&&, E&&, EVS) diff --git a/docs/source/api/xadapt.rst b/docs/source/api/xadapt.rst index 761b7f5ba..86f9e4eb2 100644 --- a/docs/source/api/xadapt.rst +++ b/docs/source/api/xadapt.rst @@ -7,7 +7,7 @@ xadapt ====== -Defined in ``xtensor/xadapt.hpp`` +Defined in ``xtensor/containers/xadapt.hpp`` .. cpp:namespace-push:: xt diff --git a/docs/source/api/xarray.rst b/docs/source/api/xarray.rst index 5a081056b..18e06692e 100644 --- a/docs/source/api/xarray.rst +++ b/docs/source/api/xarray.rst @@ -7,7 +7,7 @@ xarray ====== -Defined in ``xtensor/xarray.hpp`` +Defined in ``xtensor/containers/xarray.hpp`` .. doxygenclass:: xt::xarray_container :members: diff --git a/docs/source/api/xarray_adaptor.rst b/docs/source/api/xarray_adaptor.rst index 9c40c9334..d1110c7ba 100644 --- a/docs/source/api/xarray_adaptor.rst +++ b/docs/source/api/xarray_adaptor.rst @@ -7,7 +7,7 @@ xarray_adaptor ============== -Defined in ``xtensor/xarray.hpp`` +Defined in ``xtensor/containers/xarray.hpp`` .. doxygenclass:: xt::xarray_adaptor :members: diff --git a/docs/source/api/xaxis_iterator.rst b/docs/source/api/xaxis_iterator.rst index c2fdf0372..e43bae3ee 100644 --- a/docs/source/api/xaxis_iterator.rst +++ b/docs/source/api/xaxis_iterator.rst @@ -7,7 +7,7 @@ xaxis_iterator ============== -Defined in ``xtensor/xaxis_iterator.hpp`` +Defined in ``xtensor/views/xaxis_iterator.hpp`` .. doxygenclass:: xt::xaxis_iterator :members: diff --git a/docs/source/api/xaxis_slice_iterator.rst b/docs/source/api/xaxis_slice_iterator.rst index 0e49ac075..4882fc292 100644 --- a/docs/source/api/xaxis_slice_iterator.rst +++ b/docs/source/api/xaxis_slice_iterator.rst @@ -8,7 +8,7 @@ xaxis_slice_iterator ==================== -Defined in ``xtensor/xaxis_slice_iterator.hpp`` +Defined in ``xtensor/views/xaxis_slice_iterator.hpp`` .. doxygenclass:: xt::xaxis_slice_iterator :members: diff --git a/docs/source/api/xbroadcast.rst b/docs/source/api/xbroadcast.rst index 901f429fd..e5fe1790f 100644 --- a/docs/source/api/xbroadcast.rst +++ b/docs/source/api/xbroadcast.rst @@ -7,7 +7,7 @@ xbroadcast ========== -Defined in ``xtensor/xbroadcast.hpp`` +Defined in ``xtensor/views/xbroadcast.hpp`` .. doxygenclass:: xt::xbroadcast :members: diff --git a/docs/source/api/xbuilder.rst b/docs/source/api/xbuilder.rst index 41f7b3194..b315c3730 100644 --- a/docs/source/api/xbuilder.rst +++ b/docs/source/api/xbuilder.rst @@ -7,7 +7,7 @@ xbuilder ======== -Defined in ``xtensor/xbuilder.hpp`` +Defined in ``xtensor/generators/xbuilder.hpp`` .. doxygenfunction:: xt::ones(S) @@ -19,7 +19,7 @@ Defined in ``xtensor/xbuilder.hpp`` .. doxygenfunction:: xt::empty(const S&) -.. doxygenfunction:: xt::full_like(const xexpression&) +.. doxygenfunction:: xt::full_like(const xexpression&, typename E::value_type) .. doxygenfunction:: xt::empty_like(const xexpression&) diff --git a/docs/source/api/xcontainer.rst b/docs/source/api/xcontainer.rst index 5a94dd896..24fbf6c47 100644 --- a/docs/source/api/xcontainer.rst +++ b/docs/source/api/xcontainer.rst @@ -7,7 +7,7 @@ layout ====== -Defined in ``xtensor/xlayout.hpp`` +Defined in ``xtensor/core/xlayout.hpp`` .. doxygenenum:: xt::layout_type @@ -16,7 +16,7 @@ Defined in ``xtensor/xlayout.hpp`` xcontainer ========== -Defined in ``xtensor/xcontainer.hpp`` +Defined in ``xtensor/containers/xcontainer.hpp`` .. doxygenclass:: xt::xcontainer :members: @@ -24,7 +24,7 @@ Defined in ``xtensor/xcontainer.hpp`` xstrided_container ================== -Defined in ``xtensor/xcontainer.hpp`` +Defined in ``xtensor/containers/xcontainer.hpp`` .. doxygenclass:: xt::xstrided_container :members: diff --git a/docs/source/api/xcontainer_semantic.rst b/docs/source/api/xcontainer_semantic.rst index 1162af6c4..c69866083 100644 --- a/docs/source/api/xcontainer_semantic.rst +++ b/docs/source/api/xcontainer_semantic.rst @@ -7,7 +7,7 @@ xcontainer_semantic =================== -Defined in ``xtensor/xsemantic.hpp`` +Defined in ``xtensor/core/xsemantic.hpp`` .. doxygenclass:: xt::xcontainer_semantic :members: diff --git a/docs/source/api/xcsv.rst b/docs/source/api/xcsv.rst index 2e187e92a..bc762b00f 100644 --- a/docs/source/api/xcsv.rst +++ b/docs/source/api/xcsv.rst @@ -7,7 +7,7 @@ xcsv: read/write CSV files ========================== -Defined in ``xtensor/xcsv.hpp`` +Defined in ``xtensor/io/xcsv.hpp`` .. doxygenfunction:: xt::load_csv diff --git a/docs/source/api/xexpression.rst b/docs/source/api/xexpression.rst index 800d44875..61f117592 100644 --- a/docs/source/api/xexpression.rst +++ b/docs/source/api/xexpression.rst @@ -7,7 +7,7 @@ xexpression =========== -Defined in ``xtensor/xexpression.hpp`` +Defined in ``xtensor/core/xexpression.hpp`` .. doxygenclass:: xt::xexpression :members: diff --git a/docs/source/api/xfft.rst b/docs/source/api/xfft.rst new file mode 100644 index 000000000..a05766ff7 --- /dev/null +++ b/docs/source/api/xfft.rst @@ -0,0 +1,16 @@ +.. Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht + + Distributed under the terms of the BSD 3-Clause License. + + The full license is in the file LICENSE, distributed with this software. + +xfft +==== + +Defined in ``xtensor/misc/xfft.hpp`` + +.. doxygenfunction:: xt::fft::fft(E&&, std::ptrdiff_t) + +.. doxygenfunction:: xt::fft::ifft(E&&, std::ptrdiff_t) + +.. doxygenfunction:: xt::fft::convolve(E1&&, E2&&, std::ptrdiff_t) diff --git a/docs/source/api/xfixed.rst b/docs/source/api/xfixed.rst index f00dabb6d..b9afc6d7b 100644 --- a/docs/source/api/xfixed.rst +++ b/docs/source/api/xfixed.rst @@ -7,7 +7,7 @@ xtensor_fixed ============= -Defined in ``xtensor/xfixed.hpp`` +Defined in ``xtensor/containers/xfixed.hpp`` .. doxygenclass:: xt::xfixed_container :members: diff --git a/docs/source/api/xfunction.rst b/docs/source/api/xfunction.rst index 9dd42a79b..e572e463b 100644 --- a/docs/source/api/xfunction.rst +++ b/docs/source/api/xfunction.rst @@ -7,11 +7,11 @@ xfunction ========= -Defined in ``xtensor/xfunction.hpp`` +Defined in ``xtensor/core/xfunction.hpp`` .. doxygenclass:: xt::xfunction :members: -Defined in ``xtensor/xmath.hpp`` +Defined in ``xtensor/core/xmath.hpp`` .. doxygenfunction:: make_lambda_xfunction diff --git a/docs/source/api/xgenerator.rst b/docs/source/api/xgenerator.rst index f5d09ef65..8d96da7f3 100644 --- a/docs/source/api/xgenerator.rst +++ b/docs/source/api/xgenerator.rst @@ -7,7 +7,7 @@ xgenerator ========== -Defined in ``xtensor/xgenerator.hpp`` +Defined in ``xtensor/generators/xgenerator.hpp`` .. doxygenclass:: xt::xgenerator :members: diff --git a/docs/source/api/xhistogram.rst b/docs/source/api/xhistogram.rst index 073d75ef6..4d1e3e639 100644 --- a/docs/source/api/xhistogram.rst +++ b/docs/source/api/xhistogram.rst @@ -7,37 +7,16 @@ xhistogram ========== -Defined in ``xtensor/xhistogram.hpp`` +Defined in ``xtensor/misc/xhistogram.hpp`` -.. doxygenenum:: xt::histogram_algorithm +.. doxygengroup:: digitize + :members: -.. doxygenfunction:: xt::histogram(E1&&, E2&&, E3&&, bool) +.. doxygengroup:: histogram + :members: .. doxygenfunction:: xt::bincount(E1&&, E2&&, std::size_t) -.. doxygenfunction:: xt::histogram_bin_edges(E1&&, E2&&, E3, E3, std::size_t, histogram_algorithm) - -.. doxygenfunction:: xt::digitize(E1&&, E2&&, E3&&, bool, bool) - .. doxygenfunction:: xt::bin_items(size_t, E&&) -Further overloads ------------------ - -.. doxygenfunction:: xt::histogram(E1&&, E2&&, bool) - -.. doxygenfunction:: xt::histogram(E1&&, std::size_t, bool) - -.. doxygenfunction:: xt::histogram(E1&&, std::size_t, E2, E2, bool) - -.. doxygenfunction:: xt::histogram(E1&&, std::size_t, E2&&, bool) - -.. doxygenfunction:: xt::histogram(E1&&, std::size_t, E2&&, E3, E3, bool) - -.. doxygenfunction:: xt::histogram_bin_edges(E1&&, E2, E2, std::size_t, histogram_algorithm) - -.. doxygenfunction:: xt::histogram_bin_edges(E1&&, E2&&, std::size_t, histogram_algorithm) - -.. doxygenfunction:: xt::histogram_bin_edges(E1&&, std::size_t, histogram_algorithm) - .. doxygenfunction:: xt::bin_items(size_t, size_t) diff --git a/docs/source/api/xindex_view.rst b/docs/source/api/xindex_view.rst index 8fa1619e0..d47ab3733 100644 --- a/docs/source/api/xindex_view.rst +++ b/docs/source/api/xindex_view.rst @@ -7,7 +7,7 @@ xindex_view =========== -Defined in ``xtensor/xindex_view.hpp`` +Defined in ``xtensor/views/xindex_view.hpp`` .. doxygenclass:: xt::xindex_view :members: diff --git a/docs/source/api/xio.rst b/docs/source/api/xio.rst index 3b2a0587d..7af4c5d09 100644 --- a/docs/source/api/xio.rst +++ b/docs/source/api/xio.rst @@ -7,15 +7,15 @@ xio: pretty printing ==================== -Defined in ``xtensor/xio.hpp`` +Defined in ``xtensor/io/xio.hpp`` This file defines functions for pretty printing xexpressions. It defines appropriate overloads for the ``<<`` operator for std::ostreams and xexpressions. .. code:: - #include - #include + #include + #include int main() { diff --git a/docs/source/api/xiterable.rst b/docs/source/api/xiterable.rst index 2e7d1a98b..f0ad5637d 100644 --- a/docs/source/api/xiterable.rst +++ b/docs/source/api/xiterable.rst @@ -7,7 +7,7 @@ xiterable ========= -Defined in ``xtensor/xiterable.hpp`` +Defined in ``xtensor/core/xiterable.hpp`` .. doxygenclass:: xt::xconst_iterable :members: diff --git a/docs/source/api/xjson.rst b/docs/source/api/xjson.rst index 735846278..138c5b9de 100644 --- a/docs/source/api/xjson.rst +++ b/docs/source/api/xjson.rst @@ -7,8 +7,12 @@ xjson: serialize to/from JSON ============================= -Defined in ``xtensor/xjson.hpp`` +Defined in ``xtensor/io/xjson.hpp`` -.. doxygenfunction:: xt::to_json(nlohmann::json&, const E&); +Available overload families +--------------------------- -.. doxygenfunction:: xt::from_json(const nlohmann::json&, E&); +- ``xt::to_json(nlohmann::basic_json&, const E&)`` +- ``xt::from_json(const nlohmann::basic_json&, E&)`` + +``xt::from_json`` is provided for both container and view semantics. diff --git a/docs/source/api/xmanipulation.rst b/docs/source/api/xmanipulation.rst index 784dbe742..779010da5 100644 --- a/docs/source/api/xmanipulation.rst +++ b/docs/source/api/xmanipulation.rst @@ -7,7 +7,7 @@ xmanipulation ============= -Defined in ``xtensor/xmanipulation.hpp`` +Defined in ``xtensor/misc/xmanipulation.hpp`` .. cpp:namespace-push:: xt diff --git a/docs/source/api/xmasked_view.rst b/docs/source/api/xmasked_view.rst index 63ab0241b..b7df88ec3 100644 --- a/docs/source/api/xmasked_view.rst +++ b/docs/source/api/xmasked_view.rst @@ -7,7 +7,7 @@ xmasked_view ============ -Defined in ``xtensor/xmasked_view.hpp`` +Defined in ``xtensor/views/xmasked_view.hpp`` .. doxygenclass:: xt::xmasked_view :members: diff --git a/docs/source/api/xnpy.rst b/docs/source/api/xnpy.rst index f7f861db3..0c1f3320a 100644 --- a/docs/source/api/xnpy.rst +++ b/docs/source/api/xnpy.rst @@ -7,7 +7,7 @@ xnpy: read/write NPY files ========================== -Defined in ``xtensor/xnpy.hpp`` +Defined in ``xtensor/io/xnpy.hpp`` .. doxygenfunction:: xt::load_npy(std::istream&) diff --git a/docs/source/api/xoptional_assembly.rst b/docs/source/api/xoptional_assembly.rst index 8e35426ad..e40d6bd9a 100644 --- a/docs/source/api/xoptional_assembly.rst +++ b/docs/source/api/xoptional_assembly.rst @@ -7,7 +7,7 @@ xoptional_assembly ================== -Defined in ``xtensor/xoptional_assembly.hpp`` +Defined in ``xtensor/optional/xoptional_assembly.hpp`` .. doxygenclass:: xt::xoptional_assembly :members: diff --git a/docs/source/api/xoptional_assembly_adaptor.rst b/docs/source/api/xoptional_assembly_adaptor.rst index 72b44fa29..f58c06690 100644 --- a/docs/source/api/xoptional_assembly_adaptor.rst +++ b/docs/source/api/xoptional_assembly_adaptor.rst @@ -7,7 +7,7 @@ xoptional_assembly_adaptor ========================== -Defined in ``xtensor/xoptional_assembly.hpp`` +Defined in ``xtensor/optional/xoptional_assembly.hpp`` .. doxygenclass:: xt::xoptional_assembly_adaptor :members: diff --git a/docs/source/api/xoptional_assembly_base.rst b/docs/source/api/xoptional_assembly_base.rst index d65fb1f92..37fa07427 100644 --- a/docs/source/api/xoptional_assembly_base.rst +++ b/docs/source/api/xoptional_assembly_base.rst @@ -7,7 +7,7 @@ xoptional_assembly_base ======================= -Defined in ``xtensor/xoptional_assembly_base.hpp`` +Defined in ``xtensor/optional/xoptional_assembly_base.hpp`` .. doxygenclass:: xt::xoptional_assembly_base :members: diff --git a/docs/source/api/xpad.rst b/docs/source/api/xpad.rst index b4c8a169a..971a14d04 100644 --- a/docs/source/api/xpad.rst +++ b/docs/source/api/xpad.rst @@ -7,7 +7,7 @@ xpad ==== -Defined in ``xtensor/xpad.hpp`` +Defined in ``xtensor/misc/xpad.hpp`` .. doxygenenum:: xt::pad_mode diff --git a/docs/source/api/xrandom.rst b/docs/source/api/xrandom.rst index 07cd1d321..c2040e48c 100644 --- a/docs/source/api/xrandom.rst +++ b/docs/source/api/xrandom.rst @@ -7,7 +7,7 @@ xrandom ======= -Defined in ``xtensor/xrandom.hpp`` +Defined in ``xtensor/generators/xrandom.hpp`` .. warning:: xtensor uses a lazy generator for random numbers. You need to assign them or use ``eval`` to keep the generated values consistent. diff --git a/docs/source/api/xreducer.rst b/docs/source/api/xreducer.rst index 4b5570b93..4e896e099 100644 --- a/docs/source/api/xreducer.rst +++ b/docs/source/api/xreducer.rst @@ -7,9 +7,14 @@ xreducer ======== -Defined in ``xtensor/xreducer.hpp`` +Defined in ``xtensor/reducers/xreducer.hpp`` .. doxygenclass:: xt::xreducer :members: -.. doxygenfunction:: xt::reduce(F&&, E&&, X&&, EVS&&) +Available overload families +--------------------------- + +- ``xt::reduce(f, e, axes, options)`` +- ``xt::reduce(f, e, options)`` +- ``xt::reduce(f, e, const I (&axes)[N], options)`` diff --git a/docs/source/api/xrepeat.rst b/docs/source/api/xrepeat.rst index 17fd209b7..5e3db7c82 100644 --- a/docs/source/api/xrepeat.rst +++ b/docs/source/api/xrepeat.rst @@ -7,7 +7,7 @@ xrepeat ======= -Defined in ``xtensor/xrepeat.hpp`` +Defined in ``xtensor/views/xrepeat.hpp`` .. doxygenclass:: xt::xrepeat :members: diff --git a/docs/source/api/xsemantic_base.rst b/docs/source/api/xsemantic_base.rst index 9ce72c7b7..c6062cf91 100644 --- a/docs/source/api/xsemantic_base.rst +++ b/docs/source/api/xsemantic_base.rst @@ -7,7 +7,7 @@ xsemantic_base ============== -Defined in ``xtensor/xsemantic.hpp`` +Defined in ``xtensor/core/xsemantic.hpp`` .. doxygenclass:: xt::xsemantic_base :members: diff --git a/docs/source/api/xset_operation.rst b/docs/source/api/xset_operation.rst index 4ce798e38..14ea65cda 100644 --- a/docs/source/api/xset_operation.rst +++ b/docs/source/api/xset_operation.rst @@ -7,21 +7,15 @@ xset_operation ============== -Defined in ``xtensor/xset_operation.hpp`` +Defined in ``xtensor/misc/xset_operation.hpp`` -.. doxygenenum:: xt::isin(E&&, F&&) +``xt::searchsorted(a, v, right)`` returns insertion indices for values ``v`` +in the sorted array ``a``. -.. doxygenenum:: xt::in1d(E&&, F&&) +Available functions +------------------- -.. doxygenenum:: xt::searchsorted(E1&&, E2&&, bool) - -Further overloads ------------------ - -.. doxygenenum:: xt::isin(E&&, std::initializer_list) - -.. doxygenenum:: xt::isin(E&&, I&&, I&&) - -.. doxygenenum:: xt::in1d(E&&, std::initializer_list) - -.. doxygenenum:: xt::in1d(E&&, I&&, I&&) +- ``xt::isin(element, test_elements)`` +- ``xt::in1d(element, test_elements)`` +- ``xt::isin(element, begin, end)`` +- ``xt::in1d(element, begin, end)`` diff --git a/docs/source/api/xshape.rst b/docs/source/api/xshape.rst index 370d778ee..72f28b2ea 100644 --- a/docs/source/api/xshape.rst +++ b/docs/source/api/xshape.rst @@ -7,7 +7,7 @@ xshape ====== -Defined in ``xtensor/xshape.hpp`` +Defined in ``xtensor/core/xshape.hpp`` .. cpp:namespace-push:: xt diff --git a/docs/source/api/xsort.rst b/docs/source/api/xsort.rst index d6240d375..082532d52 100644 --- a/docs/source/api/xsort.rst +++ b/docs/source/api/xsort.rst @@ -7,7 +7,7 @@ xsort ===== -Defined in ``xtensor/xsort.hpp`` +Defined in ``xtensor/misc/xsort.hpp`` .. cpp:namespace-push:: xt diff --git a/docs/source/api/xstrided_view.rst b/docs/source/api/xstrided_view.rst index 4d308e2ff..351b09da9 100644 --- a/docs/source/api/xstrided_view.rst +++ b/docs/source/api/xstrided_view.rst @@ -7,7 +7,7 @@ xstrided_view ============= -Defined in ``xtensor/xstrided_view.hpp`` +Defined in ``xtensor/views/xstrided_view.hpp`` .. doxygenclass:: xt::xstrided_view :members: diff --git a/docs/source/api/xstrides.rst b/docs/source/api/xstrides.rst index e3143e8ca..a09540557 100644 --- a/docs/source/api/xstrides.rst +++ b/docs/source/api/xstrides.rst @@ -7,7 +7,7 @@ xstrides ======== -Defined in ``xtensor/xstrides.hpp`` +Defined in ``xtensor/core/xstrides.hpp`` .. cpp:namespace-push:: xt diff --git a/docs/source/api/xtensor.rst b/docs/source/api/xtensor.rst index 7fa987462..f896da812 100644 --- a/docs/source/api/xtensor.rst +++ b/docs/source/api/xtensor.rst @@ -7,7 +7,7 @@ xtensor ======= -Defined in ``xtensor/xtensor.hpp`` +Defined in ``xtensor/containers/xtensor.hpp`` .. doxygenclass:: xt::xtensor_container :members: diff --git a/docs/source/api/xtensor_adaptor.rst b/docs/source/api/xtensor_adaptor.rst index bc10282a7..84e21f23e 100644 --- a/docs/source/api/xtensor_adaptor.rst +++ b/docs/source/api/xtensor_adaptor.rst @@ -7,7 +7,7 @@ xtensor_adaptor =============== -Defined in ``xtensor/xtensor.hpp`` +Defined in ``xtensor/containers/xtensor.hpp`` .. doxygenclass:: xt::xtensor_adaptor :members: diff --git a/docs/source/api/xview.rst b/docs/source/api/xview.rst index 37bf7f86b..d9e72ad72 100644 --- a/docs/source/api/xview.rst +++ b/docs/source/api/xview.rst @@ -7,10 +7,9 @@ xview ===== -Defined in ``xtensor/xview.hpp`` +Defined in ``xtensor/views/xview.hpp`` .. doxygenclass:: xt::xview - :members: .. doxygenfunction:: xt::view @@ -18,7 +17,7 @@ Defined in ``xtensor/xview.hpp`` .. doxygenfunction:: xt::col -Defined in ``xtensor/xslice.hpp`` +Defined in ``xtensor/views/xslice.hpp`` .. doxygenfunction:: xt::range(A, B) diff --git a/docs/source/api/xview_semantic.rst b/docs/source/api/xview_semantic.rst index c8f5a39bd..211b27223 100644 --- a/docs/source/api/xview_semantic.rst +++ b/docs/source/api/xview_semantic.rst @@ -7,7 +7,7 @@ xview_semantic ============== -Defined in ``xtensor/xsemantic.hpp`` +Defined in ``xtensor/core/xsemantic.hpp`` .. doxygenclass:: xt::xview_semantic :members: diff --git a/docs/source/build-options.rst b/docs/source/build-options.rst index b076c422b..25e32ceb9 100644 --- a/docs/source/build-options.rst +++ b/docs/source/build-options.rst @@ -120,4 +120,4 @@ Notice that this option prevents building on a machine and distributing the resu a different architecture (i.e. not supporting the same instruction set). .. _xsimd: https://github.com/xtensor-stack/xsimd -.. _tbb: https://www.threadingbuildingblocks.org +.. _tbb: https://github.com/uxlfoundation/oneTBB diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 0083461b6..982773051 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -7,6 +7,108 @@ Changelog ========= +0.27.1 +------ + +- Add tagfiles to support fetching documentation with xeus-cpp-lite + `# 2862 https://github.com/xtensor-stack/xtensor/pull/2862` + +0.27.0 +------ + +- Replaced apply_cv with xtl::apply_cv and deleted duplicated code + `# 2836 https://github.com/xtensor-stack/xtensor/pull/2836` +- Implement apply with std 17 + `# 2835 https://github.com/xtensor-stack/xtensor/pull/2835` +- feat: Use cpp20 by default + `# 2839 https://github.com/xtensor-stack/xtensor/pull/2839` +- Set C++20 in clang-format + `# 2843 https://github.com/xtensor-stack/xtensor/pull/2843` +- Update docs to reflect new directory structure. + `# 2845 https://github.com/xtensor-stack/xtensor/pull/2845` +- Adding concept to a part of the code + `# 2842 https://github.com/xtensor-stack/xtensor/pull/2842` +- fix: update benchmarks + `# 2848 https://github.com/xtensor-stack/xtensor/pull/2848` +- Revive benchmarks + `# 2854 https://github.com/xtensor-stack/xtensor/pull/2854` +- Set cmake min version to represent used features. + `# 2852 https://github.com/xtensor-stack/xtensor/pull/2852` +- Enabling rich display for xeus-cpp-lite + `# 2853 https://github.com/xtensor-stack/xtensor/pull/2853` +- Add braces around initializers + `# 2855 https://github.com/xtensor-stack/xtensor/pull/2855` +- Adding concept to a part of the code (part 2) + `# 2846 https://github.com/xtensor-stack/xtensor/pull/2846` +- cmake: write xtensor.hpp to local dir to keep global build dir clean + `# 2857 https://github.com/xtensor-stack/xtensor/pull/2857` + +0.26.0 +------ + +- Adding the ability to enable memory overlap check in assignment to avoid unneeded temporary memory allocation + `# 2768 https://github.com/xtensor-stack/xtensor/pull/2768` +- Pure xtensor FFT implementation + `# 2782 https://github.com/xtensor-stack/xtensor/pull/2782` +- Update for C++ 20 compatibility + `# 2774 https://github.com/xtensor-stack/xtensor/pull/2774` +- Fixed CI added OSX 13 and GCC 12 + `# 2796 https://github.com/xtensor-stack/xtensor/pull/2796` +- Fix compile issue with clang 19.1.1 + `# 2813 https://github.com/xtensor-stack/xtensor/pull/2813` +- Avoid warnings in compiler version checks + `# 2781 https://github.com/xtensor-stack/xtensor/pull/2781` +- Bump OSX Version 12 -> 13 to avoid deprecated environment + `# 2818 https://github.com/xtensor-stack/xtensor/pull/2818` +- Update gh-pages.yml + `# 2824 https://github.com/xtensor-stack/xtensor/pull/2824` +- Upgraded to xsimd 13.2.0 + `# 2825 https://github.com/xtensor-stack/xtensor/pull/2825` +- Added missing configuration key for RTD + `# 2826 https://github.com/xtensor-stack/xtensor/pull/2826` +- Code reorganization + `# 2829 https://github.com/xtensor-stack/xtensor/pull/2829` +- Adding fix for incorrect usage of xt::has_assign_conversion in xassig + `# 2830 https://github.com/xtensor-stack/xtensor/pull/2830` +- Upgraded to xtl 0.8.0 and C++17 + `# 2831 https://github.com/xtensor-stack/xtensor/pull/2831` +- Migrated to more recent compilers + `# 2832 https://github.com/xtensor-stack/xtensor/pull/2832` +- Fix for Clang19 + `# 2833 https://github.com/xtensor-stack/xtensor/pull/2833` + +0.25.0 +------ + +- Fix conversion warning in xrepeat + `# 2732 https://github.com/xtensor-stack/xtensor/pull/2732` +- Upraded to xsimd 11 + `# 2735 https://github.com/xtensor-stack/xtensor/pull/2735` +- Update to use XTENSOR_DEFAULT_ALIGNMENT when using XSIMD + `# 2739 https://github.com/xtensor-stack/xtensor/pull/2739` +- Removed failing test xinfo on clang 16 + `# 2740 https://github.com/xtensor-stack/xtensor/pull/2740` +- [CI] Switching to mamba-org/setup-micromamba + `# 2742 https://github.com/xtensor-stack/xtensor/pull/2742` +- Bump cmake version and resolve build issues + `# 2744 https://github.com/xtensor-stack/xtensor/pull/2744` +- Make reshape_view accept -1 as a wildcard dimension + `# 2746 https://github.com/xtensor-stack/xtensor/pull/2746` +- Fixing bug in argmin/argmax called with axis on rank-1 container + `# 2753 https://github.com/xtensor-stack/xtensor/pull/2753` +- pre-commit autoupdate + `# 2754 https://github.com/xtensor-stack/xtensor/pull/2754` +- Use L suffix for long double constants + `# 2762 https://github.com/xtensor-stack/xtensor/pull/2762` +- Use 1/4 step for testing arange + `# 2763 https://github.com/xtensor-stack/xtensor/pull/2763` +- [Optimization] Updated concatenate_access and stack_access to remove allocations + `# 2759 https://github.com/xtensor-stack/xtensor/pull/2759` +- [CI] Added more compilers + `# 2767 https://github.com/xtensor-stack/xtensor/pull/2767` +- Minor xindex_view to_array cleanup + `# 2765 https://github.com/xtensor-stack/xtensor/pull/2765` + 0.24.7 ------ diff --git a/docs/source/container.rst b/docs/source/container.rst index f2f644353..74367b7a8 100644 --- a/docs/source/container.rst +++ b/docs/source/container.rst @@ -41,7 +41,7 @@ The following example shows how to initialize a multi-dimensional array of dynam .. code:: #include - #include + #include std::vector shape = { 3, 2, 4 }; std::vector strides = { 8, 4, 1 }; @@ -53,7 +53,7 @@ We can use the following shortcut to specify the strides instead of computing th .. code:: #include - #include + #include std::vector shape = { 3, 2, 4 }; xt::xarray a(shape, xt::layout_type::row_major); @@ -63,7 +63,7 @@ If the layout of the array can be fixed at compile time, we can make it even sim .. code:: #include - #include + #include std::vector shape = { 3, 2, 4 }; xt::xarray a(shape); @@ -91,7 +91,7 @@ Let's use :cpp:type:`xt::xtensor` instead of :cpp:type:`xt::xarray` in the previ .. code:: #include - #include + #include std::array shape = { 3, 2, 4 }; xt::xtensor a(shape); @@ -102,7 +102,7 @@ Or when using :cpp:type:`xt::xtensor_fixed`: .. code:: - #include + #include xt::xtensor_fixed> a(); // or xt::xtensor_fixed, xt::layout_type::row_major>() @@ -128,7 +128,7 @@ remain the same: .. code:: - #include + #include xt::xarray a = { 1, 2, 3, 4, 5, 6, 7, 8}; // The following two lines ... @@ -145,7 +145,7 @@ In this case, the value is inferred from the number of elements in the container .. code:: - #include + #include xt::xarray a = { 1, 2, 3, 4, 5, 6, 7, 8}; a.reshape({2, -1}); // a.shape() return {2, 4} @@ -183,8 +183,8 @@ A mechanism is provided to forcibly prevent usage of a temporary variable: .. code:: - #include - #include + #include + #include // a, b, and c are xt::xarrays previously initialized xt::noalias(b) = a + c; @@ -199,7 +199,7 @@ The aliasing phenomenon is illustrated in the following example: .. code:: #include - #include + #include std::vector a_shape = {3, 2, 4}; xt::xarray a(a_shape); diff --git a/docs/source/dev-build-options.rst b/docs/source/dev-build-options.rst index 67fbab9a6..c4b12a8fe 100644 --- a/docs/source/dev-build-options.rst +++ b/docs/source/dev-build-options.rst @@ -100,4 +100,4 @@ You can then build the documentation: Type ``make help`` to see the list of available documentation targets. .. _xsimd: https://github.com/xtensor-stack/xsimd -.. _tbb: https://www.threadingbuildingblocks.org +.. _tbb: https://github.com/uxlfoundation/oneTBB diff --git a/docs/source/developer/concepts.rst b/docs/source/developer/concepts.rst index fa8809599..06de0ffd2 100644 --- a/docs/source/developer/concepts.rst +++ b/docs/source/developer/concepts.rst @@ -26,7 +26,7 @@ class whose template parameter is ``A`` and should forward this parameter to :cp .. code:: - #include + #include template class B : public xexpression @@ -55,7 +55,7 @@ xiterable ~~~~~~~~~ The iterable concept is modeled by two classes, ``xconst_iterable`` and ``xiterable``, defined -in ``xtensor/xiterable.hpp``. ``xconst_iterable`` provides types and methods for iterating on +in ``xtensor/core/xiterable.hpp``. ``xconst_iterable`` provides types and methods for iterating on constant expressions, similar to the ones provided by the STL containers. Unlike the STL, the methods of ``xconst_iterable`` and ``xiterable`` are templated by a layout parameter that allows you to iterate over a N-dimensional expression in row-major order or column-major order. @@ -111,7 +111,7 @@ given shape: #include #include #include - #include + #include int main(int argc, char* argv[]) { @@ -146,8 +146,8 @@ The first overload is meant for computed assignment involving a scalar; it allow .. code:: - #include - #include + #include + #include int main(int argc, char* argv) { diff --git a/docs/source/expression.rst b/docs/source/expression.rst index 6bbaf9b2e..8aa5d7324 100644 --- a/docs/source/expression.rst +++ b/docs/source/expression.rst @@ -128,7 +128,7 @@ You can access the elements of any :cpp:type:`xt::xexpression` with :cpp:func:`~ .. code:: - #include + #include xt::xarray a = {{1., 2., 3.}, {4., 5., 6.}}; auto f = 2 * a; @@ -145,7 +145,7 @@ of the expression: .. code:: - #include + #include xt::xarray a = {{1., 2., 3.}, {4., 5., 6.}}; @@ -169,7 +169,7 @@ Shape .. code:: #include - #include + #include using array_type = xt::xarray; using shape_type = array_type::shape_type; @@ -199,7 +199,7 @@ Element access .. code:: #include - #inclde "xtensor/xarray.hpp" + #inclde "xtensor/containers/xarray.hpp" // xt::xarray a = ... std::vector index = {1, 1, 1}; @@ -232,5 +232,5 @@ Iterators :cpp:func:`begin(shape) ` and :cpp:func:`end(shape) `. -.. _NumPy: http://www.numpy.org +.. _NumPy: https://numpy.org/ .. _libdynd: http://libdynd.org diff --git a/docs/source/external-structures.rst b/docs/source/external-structures.rst index b85fcd02f..4d82738f2 100644 --- a/docs/source/external-structures.rst +++ b/docs/source/external-structures.rst @@ -47,7 +47,7 @@ Adapting a pointer ------------------ Suppose that you want to use the *xtensor* machinery on a small contiguous subset of a large tensor. -You can, of course, use :ref:`Views`, but for efficiency you can also use pointers to the right bit of memory. +You can, of course, use :ref:`view-description`, but for efficiency you can also use pointers to the right bit of memory. Consider an example of an ``[M, 2, 2]`` tensor ``A``, for which you want to operate on ``A[i, :, :]`` for different ``i``. In this case the most efficient *xtensor* has to offer is: @@ -207,7 +207,7 @@ strides based on the shape and the layout, so the implementation of the ``resize .. code:: - #include // for utility functions + #include // for utility functions template void resize(const shape_type& shape) @@ -464,7 +464,7 @@ This part is relatively straightforward: template bool broadcast_shape(const S& s) const { - // Available in "xtensor/xtrides.hpp" + // Available in "xtensor/core/xstrides.hpp" return xt::broadcast_shape(shape(), s); } diff --git a/docs/source/file_loading.rst b/docs/source/file_loading.rst index 917eaa9b3..348b12e40 100644 --- a/docs/source/file_loading.rst +++ b/docs/source/file_loading.rst @@ -28,8 +28,8 @@ save data in the Comma-separated value format. The reference documentation is :d #include #include - #include - #include + #include + #include int main() { @@ -59,8 +59,8 @@ Reference documentation for the functions used is found here :doc:`api/xnpy`. #include #include - #include - #include + #include + #include int main() { @@ -85,8 +85,8 @@ The reference documentation is found :doc:`api/xjson`. .. code:: - #include - #include + #include + #include int main() { diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index f37007528..45f315f8a 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -16,9 +16,9 @@ First example .. code:: #include - #include - #include - #include + #include + #include + #include int main(int argc, char* argv[]) { @@ -142,8 +142,8 @@ This second example initializes a 1-dimensional array and reshapes it in-place: .. code:: #include - #include - #include + #include + #include int main(int argc, char* argv[]) { @@ -177,7 +177,7 @@ When compiled and run, this produces the following output: .. code-block:: cpp - std::cout << xt::adapt(arr.shape()); // with: #include + std::cout << xt::adapt(arr.shape()); // with: #include Third example: index access --------------------------- @@ -185,8 +185,8 @@ Third example: index access .. code:: #include - #include - #include + #include + #include int main(int argc, char* argv[]) { @@ -219,9 +219,9 @@ This last example shows how to broadcast the :cpp:func:`xt::pow` universal funct .. code:: #include - #include - #include - #include + #include + #include + #include int main(int argc, char* argv[]) { diff --git a/docs/source/histogram.rst b/docs/source/histogram.rst index f7796ce04..f1e37c94c 100644 --- a/docs/source/histogram.rst +++ b/docs/source/histogram.rst @@ -30,9 +30,9 @@ with that difference that the bin-edges are obtained by a separate function call .. code-block:: cpp - #include - #include - #include + #include + #include + #include int main() { @@ -53,9 +53,9 @@ To customize the algorithm to be used to construct the histogram, one needs to m .. code-block:: cpp - #include - #include - #include + #include + #include + #include int main() { diff --git a/docs/source/index.rst b/docs/source/index.rst index 2aea4cb71..d28e135ea 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -119,7 +119,7 @@ for details. related bindings -.. _NumPy: http://www.numpy.org +.. _NumPy: https://numpy.org/ .. _Buffer Protocol: https://docs.python.org/3/c-api/buffer.html .. _libdynd: http://libdynd.org .. _xtensor-python: https://github.com/xtensor-stack/xtensor-python diff --git a/docs/source/indices.rst b/docs/source/indices.rst index cf51597f6..e32fce8c7 100644 --- a/docs/source/indices.rst +++ b/docs/source/indices.rst @@ -14,9 +14,9 @@ There are two types of indices: *array indices* and *flat indices*. Consider thi .. code-block:: cpp - #include - #include - #include + #include + #include + #include int main() { @@ -183,9 +183,9 @@ For the same example: .. code-block:: cpp - #include - #include - #include + #include + #include + #include int main() { @@ -222,9 +222,9 @@ For example: .. code-block:: cpp - #include - #include - #include + #include + #include + #include int main() { @@ -252,10 +252,10 @@ For example .. code-block:: cpp - #include - #include - #include - #include + #include + #include + #include + #include int main() { diff --git a/docs/source/numpy-differences.rst b/docs/source/numpy-differences.rst index fe162b6ae..03968685e 100644 --- a/docs/source/numpy-differences.rst +++ b/docs/source/numpy-differences.rst @@ -32,8 +32,8 @@ array argument is a 0-D argument: .. code:: - #include - #include + #include + #include xt::xarray x = 1; std::cout << xt::cumsum(x, 0) << std::endl; diff --git a/docs/source/operator.rst b/docs/source/operator.rst index bca7c1595..7323ed5a3 100644 --- a/docs/source/operator.rst +++ b/docs/source/operator.rst @@ -26,7 +26,7 @@ rules explained in a previous section. .. code:: - #incude "xtensor/xarray.hpp" + #incude "xtensor/containers/xarray.hpp" xt::xarray a = {{1, 2}, {3, 4}}; xt::xarray b = {1, 2}; @@ -58,7 +58,7 @@ and an element-wise ternary function (similar to the ``: ?`` ternary operator): .. code:: - #include + #include xt::xarray b = { false, true, true, false }; xt::xarray a1 = { 1, 2, 3, 4 }; @@ -86,7 +86,7 @@ C++ inequality operators: they are element-wise operators returning boolean .. code:: - #include + #include xt::xarray a1 = { 1, 12, 3, 14 }; xt::xarray a2 = { 11, 2, 13, 4 }; @@ -105,7 +105,7 @@ function. .. code:: - #include + #include xt::xarray a1 = { 1, 2, 3, 4}; xt::xarray a2 = { 11, 12, 3, 4}; @@ -153,7 +153,7 @@ performed via :cpp:func:`xt::cast`, which performs an element-wise ``static_cast .. code:: - #include + #include xt::xarray a = { 3, 5, 7 }; @@ -173,8 +173,8 @@ axes removed. .. code:: - #include - #include + #include + #include xt::xarray a = xt::ones({3, 2, 4, 6, 5}); xt::xarray res = xt::sum(a, {1, 3}); @@ -185,8 +185,8 @@ You can also call the :cpp:func:`xt::reduce` generator with your own reducing fu .. code:: - #include - #include + #include + #include xt::xarray arr = some_init_function({3, 2, 4, 6, 5}); xt::xarray res = xt::reduce([](double a, double b) { return a*a + b*b; }, @@ -199,8 +199,8 @@ A generator is provided to build the :cpp:type:`xt::xreducer_functors` object, t .. code:: - #include - #include + #include + #include xt::xarray arr = some_init_function({3, 2, 4, 6, 5}); xt::xarray res = xt::reduce(xt::make_xreducer_functor([](double a, double b) { return a*a + b*b; }, @@ -214,8 +214,8 @@ the evaluation and get the result: .. code:: - #include - #include + #include + #include xt::xarray arr = some_init_function({3, 2, 4, 6, 5}); double res = xt::reduce([](double a, double b) { return a*a + b*b; }, arr)(); @@ -232,8 +232,8 @@ computation: .. code:: - #include - #include + #include + #include xt::xarray arr = some_init_function({3, 2, 4, 6, 5}); auto s1 = xt::sum(arr); // No effect, short + int = int @@ -244,8 +244,8 @@ as shown below: .. code:: - #include - #include + #include + #include template void my_computation(E&& e) @@ -264,8 +264,8 @@ or :cpp:type:`xt::xtensor`. .. code:: - #include - #include + #include + #include xt::xarray a = xt::ones({5, 8, 3}); xt::xarray res = xt::cumsum(a, 1); @@ -278,8 +278,8 @@ function. For example, the implementation of cumsum is as follows: .. code:: - #include - #include + #include + #include xt::xarray arr = some_init_function({5, 5, 5}); xt::xarray res = xt::accumulate([](double a, double b) { return a + b; }, @@ -292,8 +292,8 @@ with the same rules as those for reducers: .. code:: - #include - #include + #include + #include xt::xarray arr = some_init_function({5, 5, 5}); auto r1 = xt::cumsum(a, 1); @@ -323,8 +323,8 @@ Choosing an evaluation_strategy is straightforward. For reducers: .. code:: - #include - #include + #include + #include xt::xarray a = xt::ones({3, 2, 4, 6, 5}); auto res = xt::sum(a, {1, 3}, xt::evaluation_strategy::immediate); @@ -351,8 +351,8 @@ arguments: .. code:: - #include - #include + #include + #include int f(int a, int b) { diff --git a/docs/source/pitfall.rst b/docs/source/pitfall.rst index e986bb40c..b9e40a2a3 100644 --- a/docs/source/pitfall.rst +++ b/docs/source/pitfall.rst @@ -70,6 +70,45 @@ in the returned expression. Replacing ``auto tmp`` with ``xt::xarray tmp`` does not change anything, ``tmp`` is still an lvalue and thus captured by reference. +.. warning:: + + This issue is particularly subtle with reducer functions like :cpp:func:`xt::amax`, + :cpp:func:`xt::sum`, etc. Consider the following function: + + .. code:: + + template + xt::xtensor logSoftmax(const xt::xtensor &matrix) + { + xt::xtensor maxVals = xt::amax(matrix, {1}, xt::keep_dims); + auto shifted = matrix - maxVals; + auto expVals = xt::exp(shifted); + auto sumExp = xt::sum(expVals, {1}, xt::keep_dims); + return shifted - xt::log(sumExp); + } + + This function may produce incorrect results or crash, especially in optimized builds. + The issue is that ``shifted``, ``expVals``, and ``sumExp`` are all lazy expressions + that hold references to local variables. When the function returns, these local + variables are destroyed, and the returned expression contains dangling references. + + The fix is to evaluate reducer results and the returned expression explicitly. + Element-wise lazy expressions (like ``shifted`` and ``expVals``) are safe to + leave as ``auto``, but reducer results (like ``sumExp``) must be materialized + before being used in a subsequent element-wise expression: + + .. code:: + + template + xt::xtensor logSoftmax(const xt::xtensor &matrix) + { + xt::xtensor maxVals = xt::amax(matrix, {1}, xt::keep_dims); + auto shifted = matrix - maxVals; + auto expVals = xt::exp(shifted); + xt::xtensor sumExp = xt::sum(expVals, {1}, xt::keep_dims); + return xt::xtensor(shifted - xt::log(sumExp)); + } + Random numbers not consistent ----------------------------- @@ -142,7 +181,7 @@ Alignment of fixed-size members When building with *xsimd* (see :ref:`external-dependencies`), if you define a structure having members of fixed-size xtensor types, you must ensure that the buffers properly aligned. For this you can use the macro ``XTENSOR_FIXED_ALIGN`` available in -``xtensor/xtensor_config.hpp``. +``xtensor/core/xtensor_config.hpp``. Consider the following example: .. code-block:: cpp diff --git a/docs/source/quickref/basic.rst b/docs/source/quickref/basic.rst index ec23e8e33..2cd4b0d2b 100644 --- a/docs/source/quickref/basic.rst +++ b/docs/source/quickref/basic.rst @@ -27,7 +27,7 @@ Tensor with dynamic shape: .. code:: - #include + #include xt::xarray::shape_type shape = {2, 3}; xt::xarray a0(shape); @@ -39,7 +39,7 @@ Tensor with static number of dimensions: .. code:: - #include + #include xt::xtensor::shape_type shape = {2, 3}; xt::xtensor a0(shape); @@ -51,7 +51,7 @@ Tensor with fixed shape: .. code:: - #include + #include xt::xtensor_fixed> = {{1., 2., 3.}, {4., 5., 6.}}; @@ -59,7 +59,7 @@ In-memory chunked tensor with dynamic shape: .. code:: - #include + #include std::vector shape = {10, 10, 10}; std::vector chunk_shape = {2, 3, 4}; @@ -70,10 +70,10 @@ Output .. code:: - #include - #include - #include - #include + #include + #include + #include + #include xt::xarray a = {{1., 2.}, {3., 4.}}; std::cout << a << std::endl; diff --git a/docs/source/quickref/chunked_arrays.rst b/docs/source/quickref/chunked_arrays.rst index 46ac95265..e645cea73 100644 --- a/docs/source/quickref/chunked_arrays.rst +++ b/docs/source/quickref/chunked_arrays.rst @@ -17,7 +17,7 @@ the chunks fit comfortably in memory, but this also allows to process them in parallel, including in a distributed environment (although this is not supported yet). -Formats for the storage of arrays such as `Zarr `_ +Formats for the storage of arrays such as `Zarr `_ specifically target chunked arrays. Such formats are becoming increasingly popular in the field of big data, since the chunks can be stored in the cloud. @@ -33,7 +33,7 @@ An in-memory chunked array has the following type: .. code:: - #include + #include using data_type = double; // don't use this code: @@ -44,7 +44,7 @@ use the ``chunked_array`` factory function: .. code:: - #include + #include std::vector shape = {10, 10, 10}; std::vector chunk_shape = {2, 3, 4}; @@ -66,4 +66,4 @@ persistence of data. In particular, they are used as a building block for the `xtensor-zarr `_ library. For further details, please refer to the documentation -of `xtensor-io `_. +of `xtensor-io `_. diff --git a/docs/source/quickref/iterator.rst b/docs/source/quickref/iterator.rst index fd8abb494..6937aa371 100644 --- a/docs/source/quickref/iterator.rst +++ b/docs/source/quickref/iterator.rst @@ -14,7 +14,7 @@ Default iteration #include #include - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}}; std::copy(a.begin(), a.end(), std::ostream_iterator(std::cout, ", ")); @@ -27,7 +27,7 @@ Specified traversal order #include #include - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}}; std::copy(a.begin(), @@ -47,7 +47,7 @@ Broacasting iteration #include #include - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}}; using shape_type = xt::dynamic_shape; @@ -73,9 +73,9 @@ Iterating over axis 0: .. code:: - #include - #include - #include + #include + #include + #include xarray a = {{{1, 2, 3, 4}, {5, 6, 7, 8}, @@ -108,9 +108,9 @@ Iterating over axis 1: .. code:: - #include - #include - #include + #include + #include + #include xarray a = {{{1, 2, 3, 4}, {5, 6, 7, 8}, @@ -139,9 +139,9 @@ Iterating over axis 2: .. code:: - #include - #include - #include + #include + #include + #include xarray a = {{{1, 2, 3, 4}, {5, 6, 7, 8}, @@ -171,9 +171,9 @@ Iterating over axis 0: .. code:: - #include - #include - #include + #include + #include + #include xarray a = {{{1, 2, 3, 4}, {5, 6, 7, 8}, @@ -200,9 +200,9 @@ Iterating over axis 1: .. code:: - #include - #include - #include + #include + #include + #include xarray a = {{{1, 2, 3, 4}, {5, 6, 7, 8}, @@ -229,9 +229,9 @@ Iterating over axis 2: .. code:: - #include - #include - #include + #include + #include + #include xarray a = {{{1, 2, 3, 4}, {5, 6, 7, 8}, diff --git a/docs/source/quickref/manipulation.rst b/docs/source/quickref/manipulation.rst index e59d4225c..d020d1fac 100644 --- a/docs/source/quickref/manipulation.rst +++ b/docs/source/quickref/manipulation.rst @@ -12,7 +12,7 @@ atleast_Nd .. code:: - #include + #include xt::xarray a0 = 123; auto r1 = xt::atleast_1d(a0); @@ -27,7 +27,7 @@ expand_dims .. code:: - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; auto r0 = xt::expand_dims(a, 0); @@ -39,7 +39,7 @@ flip .. code:: - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; auto f0 = xt::flip(a, 0); @@ -50,7 +50,7 @@ repeat .. code:: - #include + #include xt::xarray a = {{1, 2}, {3, 4}}; auto r0 = xt::repeat(a, 3, 1); @@ -61,7 +61,7 @@ roll .. code:: - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; auto t0 = xt::roll(a, 2); @@ -72,7 +72,7 @@ rot90 .. code:: - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; auto r0 = xt::rot90<1>(a); @@ -85,7 +85,7 @@ split .. code:: - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; auto s0 = xt::split(a, 3); @@ -96,7 +96,7 @@ hsplit .. code:: - #include + #include xt::xarray a = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}; auto res = xt::hsplit(a, 2); @@ -106,7 +106,7 @@ vsplit .. code:: - #include + #include xt::xarray a = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}; auto res = xt::vsplit(a, 2); @@ -116,7 +116,7 @@ squeeze .. code:: - #include + #include auto b = xt::xarray::from_shape({3, 3, 1, 1, 2, 1, 3}); auto sq0 = xt::xqueeze(b); @@ -128,7 +128,7 @@ trim_zeros .. code:: - #include + #include xt::xarray a = {0, 0, 0, 1, 3, 0}; auto t0 = xt::trim_zeros(a); diff --git a/docs/source/random.rst b/docs/source/random.rst index 69e51384a..c0f555664 100644 --- a/docs/source/random.rst +++ b/docs/source/random.rst @@ -67,8 +67,8 @@ where :math:`\alpha` is the shape (also known as :math:`k`) and :math:`\beta` th .. seealso:: * :any:`numpy.random.gamma` - * `std::gamma_distribution `_ - * `Weisstein, Eric W. "Gamma Distribution." From MathWorld – A Wolfram Web Resource. `_ + * `std::gamma_distribution `_ + * `Weisstein, Eric W. "Gamma Distribution." From MathWorld – A Wolfram Web Resource. `_ * `Wikipedia, "Gamma distribution". `_ :cpp:func:`xt::random::weibull` @@ -100,7 +100,7 @@ Note that you can specify only :math:`a` while choosing the default for :math:`b .. seealso:: * :any:`numpy.random.weibull` - * `std::weibull_distribution `_ + * `std::weibull_distribution `_ * `Wikipedia, "Weibull distribution". `_ :cpp:func:`xt::random::extreme_value` diff --git a/docs/source/related.rst b/docs/source/related.rst index dba06da63..60c640272 100644 --- a/docs/source/related.rst +++ b/docs/source/related.rst @@ -37,7 +37,7 @@ Example 1: Use an algorithm of the C++ library on a NumPy array in-place #include // Standard library import for std::accumulate #include // Pybind11 import to define Python bindings - #include // xtensor import for the C++ universal functions + #include // xtensor import for the C++ universal functions #define FORCE_IMPORT_ARRAY // NumPy C api loading #include // NumPy bindings @@ -169,7 +169,7 @@ Example 1: Use an algorithm of the C++ library with a Julia array #include // Standard library import for std::accumulate #include // CxxWrap import to define Julia bindings #include // Import the jltensor container definition - #include // xtensor import for the C++ universal functions + #include // xtensor import for the C++ universal functions double sum_of_sines(xt::jltensor m) { @@ -280,7 +280,7 @@ Example 1: Use an algorithm of the C++ library on a R array in-place .. code:: #include // Standard library import for std::accumulate - #include // xtensor import for the C++ universal functions + #include // xtensor import for the C++ universal functions #include // R bindings #include @@ -339,13 +339,13 @@ Calculate the derivative of a (discretized) field in Fourier space, e.g. a sine .. code:: - #include // rfft, irfft - #include // rfftscale - #include - #include // xt::arange - #include // xt::sin, cos + #include // rfft, irfft + #include // rfftscale + #include + #include // xt::arange + #include // xt::sin, cos #include - #include + #include // generate a sinusoid field double dx = M_PI / 100; @@ -453,12 +453,12 @@ and also provides a python wrapper based on ``xtensor-python``. .. _xtensor-r: https://github.com/xtensor-stack/xtensor-r .. _xtensor-blas: https://github.com/xtensor-stack/xtensor-blas .. _xtensor-io: https://github.com/xtensor-stack/xtensor-io -.. _xtensor-fftw: https://github.com/egpbos/xtensor-fftw -.. _xtensor-ros: https://github.com/wolfv/xtensor_ros +.. _xtensor-fftw: https://github.com/xtensor-stack/xtensor-fftw +.. _xtensor-ros: https://github.com/RoboStack/xtensor-ros .. _xsimd: https://github.com/xtensor-stack/xsimd .. _xtl: https://github.com/xtensor-stack/xtl .. _xframe: https://github.com/xtensor-stack/xframe .. _z5: https://github.com/constantinpape/z5 -.. _zarr: https://github.com/zarr-developers/zarr -.. _n5: https://github.com/saalfeldlab/n5i -.. _xarray: http://xarray.pydata.org +.. _zarr: https://github.com/zarr-developers/zarr-python +.. _n5: https://github.com/saalfeldlab/n5 +.. _xarray: https://docs.xarray.dev/en/stable/ diff --git a/docs/source/scalar.rst b/docs/source/scalar.rst index deafc7696..8d74dc8a5 100644 --- a/docs/source/scalar.rst +++ b/docs/source/scalar.rst @@ -16,7 +16,7 @@ but resized to become a 0-D array containing the scalar value: .. code:: - #include + #include xt::xarray a = {{0., 1., 2.}, {3., 4., 5.}}; double s = 1.2; @@ -36,7 +36,7 @@ Assuming that the scalar assignment does not resize the array, we have the follo .. code:: - #include + #include xt::xarray a = {{0., 1., 2.}, {3., 4., 5.}}; double s = 1.2; @@ -48,7 +48,7 @@ This is not consistent with the behavior of the copy constructor from a scalar: .. code:: - #include + #include xt::xarray a(1.2); std::cout << a << std::endl; @@ -59,7 +59,7 @@ a scalar: .. code:: - #include + #include xt::xarray a = {{0., 1., 2.}, {3., 4., 5.}}; a = 1.2; diff --git a/docs/source/view.rst b/docs/source/view.rst index 66a3897b4..95b6365b8 100644 --- a/docs/source/view.rst +++ b/docs/source/view.rst @@ -33,8 +33,8 @@ Slices can be specified in the following ways: .. code:: #include - #include - #include + #include + #include std::vector shape = {3, 2, 4}; xt::xarray a(shape); @@ -70,8 +70,8 @@ The range function supports the placeholder ``_`` syntax: .. code:: - #include - #include + #include + #include using namespace xt::placeholders; // required for ``_`` to work @@ -87,8 +87,8 @@ you are actually also altering the underlying expression. .. code:: #include - #include - #include + #include + #include std::vector shape = {3, 2, 4}; xt::xarray a(shape, 0); @@ -102,8 +102,8 @@ The convenient methods :cpp:func:`xt::row` and :cpp:func:`xt::col` are available .. code:: #include - #include - #include + #include + #include xt::xtensor a = {{1, 2}, {3, 4}}; auto r = xt::row(a, 0); @@ -125,8 +125,8 @@ The strided view does not support the slices returned by the :cpp:func:`xt::keep .. code:: - #include - #include + #include + #include auto a = xt::xarray::from_shape({3, 2, 3, 4, 5}); @@ -149,8 +149,8 @@ Since ``xtensor 0.16.3``, a new range syntax can be used with strided views: .. code:: - #include - #include + #include + #include using namespace xt::placeholders; @@ -159,9 +159,9 @@ Since ``xtensor 0.16.3``, a new range syntax can be used with strided views: // The previous line is equivalent to auto v2 = xt::strided_view(a, {xt::range(0, 1), 1, xt::range(_, 2), xt::range(_, _, -1)}); -The :cpp:type:`xt::xstrided_view` is very efficient on contigous memory -(e.g. :cpp:type:`xt::xtensor` or :cpp:type:`xt::xarray`) but less efficient on\ -:cpp:type:`xt::xexpression`s. +The :cpp:type:`xt::xstrided_view` type is very efficient on contigous memory +(e.g. :cpp:type:`xt::xtensor` or :cpp:type:`xt::xarray`) but less efficient on +generic :cpp:type:`xt::xexpression` objects. Transposed views ---------------- @@ -171,8 +171,8 @@ Trying to build a transposed view on a expression with a dynamic layout throws a .. code:: - #include - #include + #include + #include xt::xarray a = { {0, 1, 2}, {3, 4, 5} }; auto tr = xt::transpose(a); @@ -194,8 +194,8 @@ uses the layout of the expression. .. code:: - #include - #include + #include + #include xt::xarray a = { {0, 1, 2}, {3, 4, 5} }; auto flc = xt::ravel(a); @@ -217,8 +217,8 @@ the view modifies the underlying expression. .. code:: - #include - #include + #include + #include auto a = xt::xarray::from_shape({3, 2, 4}); auto v = xt::reshape_view(a, { 4, 2, 3 }); @@ -240,7 +240,7 @@ keeping or dropping of a slice is involved. .. code:: - #include + #include #include auto a = xt::xarray::from_shape({3, 2, 3, 4, 5}); @@ -266,8 +266,8 @@ Index views should be built with the :cpp:func:`xt::index_view` helper function. .. code:: - #include - #include + #include + #include xt::xarray a = {{1, 5, 3}, {4, 5, 6}}; auto b = xt::index_view(a, {{0,0}, {1, 0}, {0, 1}}); @@ -280,8 +280,8 @@ The same stands for the type of the list of indices: .. code:: - #include - #include + #include + #include xt::xarray a = {{1, 5, 3}, {4, 5, 6}}; using index_type = std::array; @@ -300,8 +300,8 @@ Filters should be built with the :cpp:func:`xt::filter` helper function. .. code:: - #include - #include + #include + #include xt::xarray a = {{1, 5, 3}, {4, 5, 6}}; auto v = xt::filter(a, a >= 5); @@ -320,8 +320,8 @@ computed scalar assignments. .. code:: - #include - #include + #include + #include xt::xarray a = {{1, 5, 3}, {4, 5, 6}}; filtration(a, a >= 5) += 100; @@ -334,8 +334,8 @@ Masked views are multidimensional views that apply a mask on an :cpp:type:`xt::x .. code:: - #include - #include + #include + #include xt::xarray a = {{1, 5, 3}, {4, 5, 6}}; xt::xarray mask = {{true, false, false}, {false, true, false}}; @@ -357,8 +357,8 @@ Broadcasting views should be built with the :cpp:func:`xt::broadcast` helper fun .. code:: #include - #include - #include + #include + #include std::vector s1 = { 2, 3 }; std::vector s2 = { 3, 2, 3 }; @@ -390,8 +390,8 @@ The returned value is an expression holding a closure on the passed argument. .. code:: #include - #include - #include + #include + #include using namespace std::complex_literals; @@ -411,8 +411,8 @@ However, since views *cannot be resized*, when assigning an expression to a view .. code:: - #include - #include + #include + #include xarray a = {{0., 1., 2.}, {3., 4., 5.}}; double b = 1.2; diff --git a/docs/source/xfft.rst b/docs/source/xfft.rst new file mode 100644 index 000000000..20eed9619 --- /dev/null +++ b/docs/source/xfft.rst @@ -0,0 +1,17 @@ +.. Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht + Distributed under the terms of the BSD 3-Clause License. + The full license is in the file LICENSE, distributed with this software. +xfft +==== + +Defined in ``xtensor/misc/xfft.hpp`` + +.. doxygenclass:: xt::fft::convolve + :project: xtensor + :members: + +.. doxygentypedef:: xt::fft::fft + :project: xtensor + +.. doxygentypedef:: xt::fft::ifft + :project: xtensor diff --git a/environment-dev.yml b/environment-dev.yml index acfeaa22d..fdfc75ea9 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -3,9 +3,9 @@ channels: - conda-forge dependencies: - cmake -- xtl=0.7.5 -- xsimd=11.1.0 +- xtl=0.8.0 +- xsimd=14.2.0 - nlohmann_json -- doctest=2.4.7 +- doctest - pre-commit - ninja diff --git a/etc/xeus-cpp/tags.d/xtensor.json b/etc/xeus-cpp/tags.d/xtensor.json new file mode 100644 index 000000000..8c10f7409 --- /dev/null +++ b/etc/xeus-cpp/tags.d/xtensor.json @@ -0,0 +1,4 @@ +{ + "tagfile": "xtensor.tag", + "url": "https://xtensor.readthedocs.io/en/latest/" +} diff --git a/include/xtensor/xchunked_array.hpp b/include/xtensor/chunk/xchunked_array.hpp similarity index 99% rename from include/xtensor/xchunked_array.hpp rename to include/xtensor/chunk/xchunked_array.hpp index 3f4f619ea..dc0c16355 100644 --- a/include/xtensor/xchunked_array.hpp +++ b/include/xtensor/chunk/xchunked_array.hpp @@ -13,13 +13,13 @@ #include #include -#include "xarray.hpp" -#include "xchunked_assign.hpp" +#include "../chunk/xchunked_assign.hpp" +#include "../containers/xarray.hpp" namespace xt { /** - * @defgroup xt_xchunked_array + * @defgroup xt_xchunked_array Chunked array * * Chunked array container. * Defined in ``xtensor/xchunked_array.hpp``. diff --git a/include/xtensor/xchunked_assign.hpp b/include/xtensor/chunk/xchunked_assign.hpp similarity index 99% rename from include/xtensor/xchunked_assign.hpp rename to include/xtensor/chunk/xchunked_assign.hpp index 3ed1e5c8c..334e824b9 100644 --- a/include/xtensor/xchunked_assign.hpp +++ b/include/xtensor/chunk/xchunked_assign.hpp @@ -10,8 +10,8 @@ #ifndef XTENSOR_CHUNKED_ASSIGN_HPP #define XTENSOR_CHUNKED_ASSIGN_HPP -#include "xnoalias.hpp" -#include "xstrided_view.hpp" +#include "../core/xnoalias.hpp" +#include "../views/xstrided_view.hpp" namespace xt { diff --git a/include/xtensor/xchunked_view.hpp b/include/xtensor/chunk/xchunked_view.hpp similarity index 98% rename from include/xtensor/xchunked_view.hpp rename to include/xtensor/chunk/xchunked_view.hpp index 3a3bc79d3..6c9d0a3f2 100644 --- a/include/xtensor/xchunked_view.hpp +++ b/include/xtensor/chunk/xchunked_view.hpp @@ -12,10 +12,10 @@ #include -#include "xchunked_array.hpp" -#include "xnoalias.hpp" -#include "xstorage.hpp" -#include "xstrided_view.hpp" +#include "../chunk/xchunked_array.hpp" +#include "../containers/xstorage.hpp" +#include "../core/xnoalias.hpp" +#include "../views/xstrided_view.hpp" namespace xt { diff --git a/include/xtensor/xadapt.hpp b/include/xtensor/containers/xadapt.hpp similarity index 99% rename from include/xtensor/xadapt.hpp rename to include/xtensor/containers/xadapt.hpp index fbc7fb135..725a75d42 100644 --- a/include/xtensor/xadapt.hpp +++ b/include/xtensor/containers/xadapt.hpp @@ -17,10 +17,10 @@ #include -#include "xarray.hpp" -#include "xbuffer_adaptor.hpp" -#include "xfixed.hpp" -#include "xtensor.hpp" +#include "../containers/xarray.hpp" +#include "../containers/xbuffer_adaptor.hpp" +#include "../containers/xfixed.hpp" +#include "../containers/xtensor.hpp" namespace xt { @@ -52,13 +52,13 @@ namespace xt using default_allocator_for_ptr_t = typename default_allocator_for_ptr

::type; template - using not_an_array = xtl::negation>; + using not_an_array = std::negation>; template - using not_a_pointer = xtl::negation>; + using not_a_pointer = std::negation>; template - using not_a_layout = xtl::negation>; + using not_a_layout = std::negation>; } #ifndef IN_DOXYGEN diff --git a/include/xtensor/xarray.hpp b/include/xtensor/containers/xarray.hpp similarity index 99% rename from include/xtensor/xarray.hpp rename to include/xtensor/containers/xarray.hpp index 996daeb9d..7f27bd296 100644 --- a/include/xtensor/xarray.hpp +++ b/include/xtensor/containers/xarray.hpp @@ -11,14 +11,13 @@ #define XTENSOR_ARRAY_HPP #include -#include #include #include -#include "xbuffer_adaptor.hpp" -#include "xcontainer.hpp" -#include "xsemantic.hpp" +#include "../containers/xbuffer_adaptor.hpp" +#include "../containers/xcontainer.hpp" +#include "../core/xsemantic.hpp" namespace xt { diff --git a/include/xtensor/xbuffer_adaptor.hpp b/include/xtensor/containers/xbuffer_adaptor.hpp similarity index 99% rename from include/xtensor/xbuffer_adaptor.hpp rename to include/xtensor/containers/xbuffer_adaptor.hpp index 368da5867..e59503f3a 100644 --- a/include/xtensor/xbuffer_adaptor.hpp +++ b/include/xtensor/containers/xbuffer_adaptor.hpp @@ -18,8 +18,8 @@ #include -#include "xstorage.hpp" -#include "xtensor_config.hpp" +#include "../containers/xstorage.hpp" +#include "../core/xtensor_config.hpp" namespace xt { @@ -709,7 +709,7 @@ namespace xt rhs.get_allocator() ); pointer tmp = safe_init_allocate(al, rhs.m_size); - if (xtrivially_default_constructible::value) + if (std::is_trivially_default_constructible::value) { std::uninitialized_copy(rhs.m_data.get(), rhs.m_data.get() + rhs.m_size, tmp); } diff --git a/include/xtensor/xcontainer.hpp b/include/xtensor/containers/xcontainer.hpp similarity index 97% rename from include/xtensor/xcontainer.hpp rename to include/xtensor/containers/xcontainer.hpp index 46dd0cf1b..7f17ffe01 100644 --- a/include/xtensor/xcontainer.hpp +++ b/include/xtensor/containers/xcontainer.hpp @@ -11,22 +11,20 @@ #define XTENSOR_CONTAINER_HPP #include -#include #include -#include #include #include #include -#include "xaccessible.hpp" -#include "xiterable.hpp" -#include "xiterator.hpp" -#include "xmath.hpp" -#include "xoperation.hpp" -#include "xstrides.hpp" -#include "xtensor_config.hpp" -#include "xtensor_forward.hpp" +#include "../core/xaccessible.hpp" +#include "../core/xiterable.hpp" +#include "../core/xiterator.hpp" +#include "../core/xmath.hpp" +#include "../core/xoperation.hpp" +#include "../core/xstrides.hpp" +#include "../core/xtensor_config.hpp" +#include "../core/xtensor_forward.hpp" namespace xt { @@ -116,11 +114,11 @@ namespace xt size_type size() const noexcept; - XTENSOR_CONSTEXPR_RETURN size_type dimension() const noexcept; + constexpr size_type dimension() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides() const noexcept; + constexpr const inner_shape_type& shape() const noexcept; + constexpr const inner_strides_type& strides() const noexcept; + constexpr const inner_backstrides_type& backstrides() const noexcept; template void fill(const T& value); @@ -375,7 +373,7 @@ namespace xt * Returns the number of dimensions of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::dimension() const noexcept -> size_type + constexpr auto xcontainer::dimension() const noexcept -> size_type { return shape().size(); } @@ -384,7 +382,7 @@ namespace xt * Returns the shape of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::shape() const noexcept -> const inner_shape_type& + constexpr auto xcontainer::shape() const noexcept -> const inner_shape_type& { return derived_cast().shape_impl(); } @@ -393,7 +391,7 @@ namespace xt * Returns the strides of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::strides() const noexcept -> const inner_strides_type& + constexpr auto xcontainer::strides() const noexcept -> const inner_strides_type& { return derived_cast().strides_impl(); } @@ -402,7 +400,7 @@ namespace xt * Returns the backstrides of the container. */ template - XTENSOR_CONSTEXPR_RETURN auto xcontainer::backstrides() const noexcept -> const inner_backstrides_type& + constexpr auto xcontainer::backstrides() const noexcept -> const inner_backstrides_type& { return derived_cast().backstrides_impl(); } @@ -999,10 +997,10 @@ namespace xt template inline void xstrided_container::resize(S&& shape, bool force) { - XTENSOR_ASSERT_MSG( + XTENSOR_PRECONDITION( detail::check_resize_dimension(m_shape, shape), "cannot change the number of dimensions of xtensor" - ) + ); std::size_t dim = shape.size(); if (m_shape.size() != dim || !std::equal(std::begin(shape), std::end(shape), std::begin(m_shape)) || force) diff --git a/include/xtensor/xfixed.hpp b/include/xtensor/containers/xfixed.hpp similarity index 91% rename from include/xtensor/xfixed.hpp rename to include/xtensor/containers/xfixed.hpp index c6ba964ed..e1b02867d 100644 --- a/include/xtensor/xfixed.hpp +++ b/include/xtensor/containers/xfixed.hpp @@ -14,15 +14,14 @@ #include #include #include -#include #include -#include "xcontainer.hpp" -#include "xsemantic.hpp" -#include "xstorage.hpp" -#include "xstrides.hpp" -#include "xtensor_config.hpp" +#include "../containers/xcontainer.hpp" +#include "../containers/xstorage.hpp" +#include "../core/xsemantic.hpp" +#include "../core/xstrides.hpp" +#include "../core/xtensor_config.hpp" namespace xtl { @@ -257,12 +256,7 @@ namespace xt using inner_backstrides_type = backstrides_type; // NOTE: 0D (S::size() == 0) results in storage for 1 element (scalar) -#if defined(_MSC_VER) && _MSC_VER < 1910 && !defined(_WIN64) - // WORKAROUND FOR MSVC 2015 32 bit, fallback to unaligned container for 0D scalar case - using storage_type = std::array::value>; -#else using storage_type = aligned_array::value>; -#endif using reference = typename storage_type::reference; using const_reference = typename storage_type::const_reference; @@ -325,9 +319,9 @@ namespace xt explicit xfixed_container(const inner_shape_type& shape, layout_type l = L); explicit xfixed_container(const inner_shape_type& shape, value_type v, layout_type l = L); - // remove this enable_if when removing the other value_type constructor - template , class EN = std::enable_if_t> - xfixed_container(nested_initializer_list_t t); + template > + xfixed_container(nested_initializer_list_t t) + requires(IX::value != 0); ~xfixed_container() = default; @@ -374,28 +368,13 @@ namespace xt storage_type& storage_impl() noexcept; const storage_type& storage_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides_impl() const noexcept; + constexpr const inner_shape_type& shape_impl() const noexcept; + constexpr const inner_strides_type& strides_impl() const noexcept; + constexpr const inner_backstrides_type& backstrides_impl() const noexcept; friend class xcontainer>; }; -#ifdef XTENSOR_HAS_CONSTEXPR_ENHANCED - // Out of line definitions to prevent linker errors prior to C++17 - template - constexpr - typename xfixed_container::inner_shape_type xfixed_container::m_shape; - - template - constexpr - typename xfixed_container::inner_strides_type xfixed_container::m_strides; - - template - constexpr typename xfixed_container::inner_backstrides_type - xfixed_container::m_backstrides; -#endif - /**************************************** * xfixed_container_adaptor declaration * ****************************************/ @@ -511,28 +490,13 @@ namespace xt storage_type& storage_impl() noexcept; const storage_type& storage_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_shape_type& shape_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_strides_type& strides_impl() const noexcept; - XTENSOR_CONSTEXPR_RETURN const inner_backstrides_type& backstrides_impl() const noexcept; + constexpr const inner_shape_type& shape_impl() const noexcept; + constexpr const inner_strides_type& strides_impl() const noexcept; + constexpr const inner_backstrides_type& backstrides_impl() const noexcept; friend class xcontainer>; }; -#ifdef XTENSOR_HAS_CONSTEXPR_ENHANCED - // Out of line definitions to prevent linker errors prior to C++17 - template - constexpr - typename xfixed_adaptor::inner_shape_type xfixed_adaptor::m_shape; - - template - constexpr - typename xfixed_adaptor::inner_strides_type xfixed_adaptor::m_strides; - - template - constexpr typename xfixed_adaptor::inner_backstrides_type - xfixed_adaptor::m_backstrides; -#endif - /************************************ * xfixed_container implementation * ************************************/ @@ -639,8 +603,9 @@ namespace xt * Note: for clang < 3.8 this is an initializer_list and the size is not checked at compile-or runtime. */ template - template + template inline xfixed_container::xfixed_container(nested_initializer_list_t t) + requires(IX::value != 0) { XTENSOR_ASSERT_MSG( detail::check_initializer_list_shape::run(t, this->shape()) == true, @@ -770,21 +735,20 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_container::shape_impl() const noexcept - -> const inner_shape_type& + constexpr auto xfixed_container::shape_impl() const noexcept -> const inner_shape_type& { return m_shape; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_container::strides_impl() const noexcept + constexpr auto xfixed_container::strides_impl() const noexcept -> const inner_strides_type& { return m_strides; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_container::backstrides_impl() const noexcept + constexpr auto xfixed_container::backstrides_impl() const noexcept -> const inner_backstrides_type& { return m_backstrides; @@ -967,21 +931,20 @@ namespace xt } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor::shape_impl() const noexcept - -> const inner_shape_type& + constexpr auto xfixed_adaptor::shape_impl() const noexcept -> const inner_shape_type& { return m_shape; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor::strides_impl() const noexcept + constexpr auto xfixed_adaptor::strides_impl() const noexcept -> const inner_strides_type& { return m_strides; } template - XTENSOR_CONSTEXPR_RETURN auto xfixed_adaptor::backstrides_impl() const noexcept + constexpr auto xfixed_adaptor::backstrides_impl() const noexcept -> const inner_backstrides_type& { return m_backstrides; diff --git a/include/xtensor/xscalar.hpp b/include/xtensor/containers/xscalar.hpp similarity index 97% rename from include/xtensor/xscalar.hpp rename to include/xtensor/containers/xscalar.hpp index 8d6e166fb..106a65923 100644 --- a/include/xtensor/xscalar.hpp +++ b/include/xtensor/containers/xscalar.hpp @@ -12,15 +12,14 @@ #include #include -#include #include -#include "xaccessible.hpp" -#include "xexpression.hpp" -#include "xiterable.hpp" -#include "xlayout.hpp" -#include "xtensor_simd.hpp" +#include "../core/xaccessible.hpp" +#include "../core/xexpression.hpp" +#include "../core/xiterable.hpp" +#include "../core/xlayout.hpp" +#include "../utils/xtensor_simd.hpp" namespace xt { @@ -317,18 +316,21 @@ namespace xt template using is_xscalar = detail::is_xscalar_impl; + template + concept xscalar_concept = is_xscalar>::value; + namespace detail { template struct all_xscalar { - static constexpr bool value = xtl::conjunction>...>::value; + static constexpr bool value = std::conjunction>...>::value; }; } // Note: MSVC bug workaround. Cannot just define // template - // using all_xscalar = xtl::conjunction>...>; + // using all_xscalar = std::conjunction>...>; template using all_xscalar = detail::all_xscalar; @@ -464,25 +466,25 @@ namespace xt *****************************/ template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(xscalar& c) noexcept -> decltype(c.dummy_begin()) + constexpr auto linear_begin(xscalar& c) noexcept -> decltype(c.dummy_begin()) { return c.dummy_begin(); } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(xscalar& c) noexcept -> decltype(c.dummy_end()) + constexpr auto linear_end(xscalar& c) noexcept -> decltype(c.dummy_end()) { return c.dummy_end(); } template - XTENSOR_CONSTEXPR_RETURN auto linear_begin(const xscalar& c) noexcept -> decltype(c.dummy_begin()) + constexpr auto linear_begin(const xscalar& c) noexcept -> decltype(c.dummy_begin()) { return c.dummy_begin(); } template - XTENSOR_CONSTEXPR_RETURN auto linear_end(const xscalar& c) noexcept -> decltype(c.dummy_end()) + constexpr auto linear_end(const xscalar& c) noexcept -> decltype(c.dummy_end()) { return c.dummy_end(); } diff --git a/include/xtensor/xstorage.hpp b/include/xtensor/containers/xstorage.hpp similarity index 93% rename from include/xtensor/xstorage.hpp rename to include/xtensor/containers/xstorage.hpp index ac179a852..26d4a8ccd 100644 --- a/include/xtensor/xstorage.hpp +++ b/include/xtensor/containers/xstorage.hpp @@ -18,21 +18,13 @@ #include #include -#include "xexception.hpp" -#include "xtensor_config.hpp" -#include "xtensor_simd.hpp" -#include "xutils.hpp" +#include "../core/xtensor_config.hpp" +#include "../utils/xexception.hpp" +#include "../utils/xtensor_simd.hpp" +#include "../utils/xutils.hpp" namespace xt { - - namespace detail - { - template - using require_input_iter = typename std::enable_if< - std::is_convertible::iterator_category, std::input_iterator_tag>::value>::type; - } - template struct is_contiguous_container : std::true_type { @@ -64,7 +56,7 @@ namespace xt explicit uvector(size_type count, const allocator_type& alloc = allocator_type()); uvector(size_type count, const_reference value, const allocator_type& alloc = allocator_type()); - template > + template uvector(InputIt first, InputIt last, const allocator_type& alloc = allocator_type()); uvector(std::initializer_list init, const allocator_type& alloc = allocator_type()); @@ -175,7 +167,7 @@ namespace xt using pointer = typename traits::pointer; using value_type = typename traits::value_type; pointer res = alloc.allocate(size); - if (!xtrivially_default_constructible::value) + if (!std::is_trivially_default_constructible::value) { for (pointer p = res; p != res + size; ++p) { @@ -197,7 +189,7 @@ namespace xt using value_type = typename traits::value_type; if (ptr != nullptr) { - if (!xtrivially_default_constructible::value) + if (!std::is_trivially_default_constructible::value) { for (pointer p = ptr; p != ptr + size; ++p) { @@ -277,7 +269,7 @@ namespace xt } template - template + template inline uvector::uvector(InputIt first, InputIt last, const allocator_type& alloc) : m_allocator(alloc) , p_begin(nullptr) @@ -333,7 +325,7 @@ namespace xt rhs.get_allocator() ); resize_impl(rhs.size()); - if (xtrivially_default_constructible::value) + if (std::is_trivially_default_constructible::value) { std::uninitialized_copy(rhs.p_begin, rhs.p_end, p_begin); } @@ -657,13 +649,9 @@ namespace xt using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; -#if defined(_MSC_VER) && _MSC_VER < 1910 - static constexpr std::size_t alignment = detail::allocator_alignment::value; -#else static constexpr std::size_t alignment = detail::allocator_alignment::value != 0 ? detail::allocator_alignment::value : alignof(T); -#endif svector() noexcept; ~svector(); @@ -675,19 +663,21 @@ namespace xt svector(const std::vector& vec); - template > + template svector(IT begin, IT end, const allocator_type& alloc = allocator_type()); - template > - explicit svector(const svector& rhs); + template + explicit svector(const svector& rhs) + requires(N != N2); svector& operator=(const svector& rhs); svector& operator=(svector&& rhs) noexcept(std::is_nothrow_move_assignable::value); svector& operator=(const std::vector& rhs); svector& operator=(std::initializer_list il); - template > - svector& operator=(const svector& rhs); + template + svector& operator=(const svector& rhs) + requires(N != N2); svector(const svector& other); svector(svector&& other) noexcept(std::is_nothrow_move_constructible::value); @@ -809,7 +799,7 @@ namespace xt } template - template + template inline svector::svector(IT begin, IT end, const allocator_type& alloc) : m_allocator(alloc) { @@ -817,8 +807,9 @@ namespace xt } template - template + template inline svector::svector(const svector& rhs) + requires(N != N2) : m_allocator(rhs.get_allocator()) { assign(rhs.begin(), rhs.end()); @@ -876,8 +867,9 @@ namespace xt } template - template + template inline svector& svector::operator=(const svector& rhs) + requires(N != N2) { m_allocator = std::allocator_traits::select_on_container_copy_construction( rhs.get_allocator() @@ -1263,7 +1255,7 @@ namespace xt template inline void svector::destroy_range(T* begin, T* end) { - if (!xtrivially_default_constructible::value) + if (!std::is_trivially_default_constructible::value) { while (begin != end) { @@ -1441,49 +1433,6 @@ namespace xt #define XTENSOR_CONST const #endif -#if defined(__GNUC__) && __GNUC__ < 5 && !defined(__clang__) -#define GCC4_FALLBACK - - namespace const_array_detail - { - template - struct array_traits - { - using storage_type = T[N]; - - static constexpr T& ref(const storage_type& t, std::size_t n) noexcept - { - return const_cast(t[n]); - } - - static constexpr T* ptr(const storage_type& t) noexcept - { - return const_cast(t); - } - }; - - template - struct array_traits - { - struct empty - { - }; - - using storage_type = empty; - - static constexpr T& ref(const storage_type& /*t*/, std::size_t /*n*/) noexcept - { - return *static_cast(nullptr); - } - - static constexpr T* ptr(const storage_type& /*t*/) noexcept - { - return nullptr; - } - }; - } -#endif - /** * A std::array like class with all member function (except reverse iterators) * as constexpr. The data is immutable once set. @@ -1506,11 +1455,7 @@ namespace xt constexpr const_reference operator[](std::size_t idx) const { -#ifdef GCC4_FALLBACK - return const_array_detail::array_traits::ref(m_data, idx); -#else return m_data[idx]; -#endif } constexpr const_iterator begin() const noexcept @@ -1556,30 +1501,17 @@ namespace xt constexpr const_pointer data() const noexcept { -#ifdef GCC4_FALLBACK - return const_array_detail::array_traits::ptr(m_data); -#else return m_data; -#endif } constexpr const_reference front() const noexcept { -#ifdef GCC4_FALLBACK - return const_array_detail::array_traits::ref(m_data, 0); -#else return m_data[0]; -#endif } constexpr const_reference back() const noexcept { -#ifdef GCC4_FALLBACK - return N ? const_array_detail::array_traits::ref(m_data, N - 1) - : const_array_detail::array_traits::ref(m_data, 0); -#else return m_data[size() - 1]; -#endif } constexpr bool empty() const noexcept @@ -1592,15 +1524,9 @@ namespace xt return N; } -#ifdef GCC4_FALLBACK - XTENSOR_CONST typename const_array_detail::array_traits::storage_type m_data; -#else XTENSOR_CONST T m_data[N > 0 ? N : 1]; -#endif }; -#undef GCC4_FALLBACK - template inline bool operator==(const const_array& lhs, const const_array& rhs) { @@ -1637,8 +1563,8 @@ namespace xt return !(lhs < rhs); } -// Workaround for rebind_container problems on GCC 8 with C++17 enabled -#if defined(__GNUC__) && __GNUC__ > 6 && !defined(__clang__) && __cplusplus >= 201703L +// Workaround for rebind_container problems when C++17 feature is enabled +#ifdef __cpp_template_template_args template struct rebind_container> { @@ -1662,13 +1588,7 @@ namespace xt { public: -#if defined(_MSC_VER) - using cast_type = std::array; -#define XTENSOR_FIXED_SHAPE_CONSTEXPR inline -#else using cast_type = const_array; -#define XTENSOR_FIXED_SHAPE_CONSTEXPR constexpr -#endif using value_type = std::size_t; using size_type = std::size_t; using const_iterator = typename cast_type::const_iterator; @@ -1685,17 +1605,17 @@ namespace xt return std::get(tmp_cast_type{X...}); } - XTENSOR_FIXED_SHAPE_CONSTEXPR operator cast_type() const + constexpr operator cast_type() const { return cast_type({X...}); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto begin() const + constexpr auto begin() const { return m_array.begin(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto end() const + constexpr auto end() const { return m_array.end(); } @@ -1710,22 +1630,32 @@ namespace xt return m_array.rend(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto cbegin() const + constexpr auto cbegin() const { return m_array.cbegin(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR auto cend() const + constexpr auto cend() const { return m_array.cend(); } - XTENSOR_FIXED_SHAPE_CONSTEXPR std::size_t operator[](std::size_t idx) const + auto crbegin() const + { + return m_array.crbegin(); + } + + auto crend() const + { + return m_array.crend(); + } + + constexpr std::size_t operator[](std::size_t idx) const { return m_array[idx]; } - XTENSOR_FIXED_SHAPE_CONSTEXPR bool empty() const + constexpr bool empty() const { return sizeof...(X) == 0; } @@ -1735,13 +1665,6 @@ namespace xt XTENSOR_CONSTEXPR_ENHANCED_STATIC cast_type m_array = cast_type({X...}); }; -#ifdef XTENSOR_HAS_CONSTEXPR_ENHANCED - template - constexpr typename fixed_shape::cast_type fixed_shape::m_array; -#endif - -#undef XTENSOR_FIXED_SHAPE_CONSTEXPR - template class sequence_view { diff --git a/include/xtensor/xtensor.hpp b/include/xtensor/containers/xtensor.hpp similarity index 99% rename from include/xtensor/xtensor.hpp rename to include/xtensor/containers/xtensor.hpp index 7b8545459..db8d92385 100644 --- a/include/xtensor/xtensor.hpp +++ b/include/xtensor/containers/xtensor.hpp @@ -16,9 +16,9 @@ #include #include -#include "xbuffer_adaptor.hpp" -#include "xcontainer.hpp" -#include "xsemantic.hpp" +#include "../containers/xbuffer_adaptor.hpp" +#include "../containers/xcontainer.hpp" +#include "../core/xsemantic.hpp" namespace xt { diff --git a/include/xtensor/xaccessible.hpp b/include/xtensor/core/xaccessible.hpp similarity index 97% rename from include/xtensor/xaccessible.hpp rename to include/xtensor/core/xaccessible.hpp index 9f74eb0b6..8ca55f8a4 100644 --- a/include/xtensor/xaccessible.hpp +++ b/include/xtensor/core/xaccessible.hpp @@ -10,9 +10,9 @@ #ifndef XTENSOR_ACCESSIBLE_HPP #define XTENSOR_ACCESSIBLE_HPP -#include "xexception.hpp" -#include "xstrides.hpp" -#include "xtensor_forward.hpp" +#include "../core/xstrides.hpp" +#include "../core/xtensor_forward.hpp" +#include "../utils/xexception.hpp" namespace xt { @@ -36,7 +36,7 @@ namespace xt using const_reference = typename inner_types::const_reference; using size_type = typename inner_types::size_type; - size_type size() const noexcept; + size_type size() const noexcept(noexcept(derived_cast().shape())); size_type dimension() const noexcept; size_type shape(size_type index) const; @@ -138,7 +138,7 @@ namespace xt * Returns the size of the expression. */ template - inline auto xconst_accessible::size() const noexcept -> size_type + inline auto xconst_accessible::size() const noexcept(noexcept(derived_cast().shape())) -> size_type { return compute_size(derived_cast().shape()); } diff --git a/include/xtensor/xassign.hpp b/include/xtensor/core/xassign.hpp similarity index 95% rename from include/xtensor/xassign.hpp rename to include/xtensor/core/xassign.hpp index d30dd6dc9..904113814 100644 --- a/include/xtensor/xassign.hpp +++ b/include/xtensor/core/xassign.hpp @@ -18,13 +18,13 @@ #include #include -#include "xexpression.hpp" -#include "xfunction.hpp" -#include "xiterator.hpp" -#include "xstrides.hpp" -#include "xtensor_config.hpp" -#include "xtensor_forward.hpp" -#include "xutils.hpp" +#include "../core/xexpression.hpp" +#include "../core/xfunction.hpp" +#include "../core/xiterator.hpp" +#include "../core/xstrides.hpp" +#include "../core/xtensor_config.hpp" +#include "../core/xtensor_forward.hpp" +#include "../utils/xutils.hpp" #if defined(XTENSOR_USE_TBB) #include @@ -214,18 +214,15 @@ namespace xt template inline void assign_xexpression(xexpression& e1, const xexpression& e2) { - xtl::mpl::static_if::value>( - [&](auto self) - { - self(e2).derived_cast().assign_to(e1); - }, - /*else*/ - [&](auto /*self*/) - { - using tag = xexpression_tag_t; - xexpression_assigner::assign_xexpression(e1, e2); - } - ); + if constexpr (has_assign_to::value) + { + e2.derived_cast().assign_to(e1); + } + else + { + using tag = xexpression_tag_t; + xexpression_assigner::assign_xexpression(e1, e2); + } } template @@ -320,7 +317,7 @@ namespace xt template struct use_strided_loop> { - static constexpr bool value = xtl::conjunction>...>::value; + static constexpr bool value = std::conjunction>...>::value; }; /** @@ -585,31 +582,28 @@ namespace xt template inline bool xexpression_assigner::resize(E1& e1, const xfunction& e2) { - return xtl::mpl::static_if::shape_type>::value>( - [&](auto /*self*/) - { - /* - * If the shape of the xfunction is statically known, we can compute the broadcast triviality - * at compile time plus we can resize right away. - */ - // resize in case LHS is not a fixed size container. If it is, this is a NOP - e1.resize(typename xfunction::shape_type{}); - return detail::static_trivial_broadcast< - detail::is_fixed::shape_type>::value, - CT...>::value; - }, - /* else */ - [&](auto /*self*/) - { - using index_type = xindex_type_t; - using size_type = typename E1::size_type; - size_type size = e2.dimension(); - index_type shape = uninitialized_shape(size); - bool trivial_broadcast = e2.broadcast_shape(shape, true); - e1.resize(std::move(shape)); - return trivial_broadcast; - } - ); + if constexpr (detail::is_fixed::shape_type>::value) + { + /* + * If the shape of the xfunction is statically known, we can compute the broadcast triviality + * at compile time plus we can resize right away. + */ + // resize in case LHS is not a fixed size container. If it is, this is a NOP + e1.resize(typename xfunction::shape_type{}); + return detail::static_trivial_broadcast< + detail::is_fixed::shape_type>::value, + CT...>::value; + } + else + { + using index_type = xindex_type_t; + using size_type = typename E1::size_type; + size_type size = e2.dimension(); + index_type shape = uninitialized_shape(size); + bool trivial_broadcast = e2.broadcast_shape(shape, true); + e1.resize(std::move(shape)); + return trivial_broadcast; + } } /*********************************** @@ -718,7 +712,7 @@ namespace xt using size_type = typename E1::size_type; size_type size = e1.size(); constexpr size_type simd_size = simd_type::size; - constexpr bool needs_cast = has_assign_conversion::value; + constexpr bool needs_cast = has_assign_conversion::value; size_type align_begin = is_aligned ? 0 : xt_simd::get_alignment_offset(e1.data(), size, simd_size); size_type align_end = align_begin + ((size - align_begin) & ~(simd_size - 1)); @@ -1131,7 +1125,7 @@ namespace xt // std::fill(idx.begin(), idx.end(), 0); using e1_value_type = typename E1::value_type; using e2_value_type = typename E2::value_type; - constexpr bool needs_cast = has_assign_conversion::value; + constexpr bool needs_cast = has_assign_conversion::value; using value_type = typename xassign_traits::requested_value_type; using simd_type = std::conditional_t< std::is_same::value, @@ -1174,7 +1168,7 @@ namespace xt for (std::size_t i = 0; i < simd_size; ++i) { - res_stepper.template store_simd(fct_stepper.template step_simd()); + res_stepper.store_simd(fct_stepper.template step_simd()); } for (std::size_t i = 0; i < simd_rest; ++i) { @@ -1249,7 +1243,7 @@ namespace xt for (std::size_t i = 0; i < simd_size; ++i) { - res_stepper.template store_simd(fct_stepper.template step_simd()); + res_stepper.store_simd(fct_stepper.template step_simd()); } for (std::size_t i = 0; i < simd_rest; ++i) { diff --git a/include/xtensor/xeval.hpp b/include/xtensor/core/xeval.hpp similarity index 97% rename from include/xtensor/xeval.hpp rename to include/xtensor/core/xeval.hpp index 69111f938..5ccbc1db9 100644 --- a/include/xtensor/xeval.hpp +++ b/include/xtensor/core/xeval.hpp @@ -10,15 +10,15 @@ #ifndef XTENSOR_EVAL_HPP #define XTENSOR_EVAL_HPP -#include "xexpression_traits.hpp" -#include "xshape.hpp" -#include "xtensor_forward.hpp" +#include "../core/xexpression_traits.hpp" +#include "../core/xshape.hpp" +#include "../core/xtensor_forward.hpp" namespace xt { /** - * @defgroup xt_xeval + * @defgroup xt_xeval Evaluation * * Evaluation functions. * Defined in ``xtensor/xeval.hpp`` diff --git a/include/xtensor/xexpression.hpp b/include/xtensor/core/xexpression.hpp similarity index 90% rename from include/xtensor/xexpression.hpp rename to include/xtensor/core/xexpression.hpp index 79fd7e4cd..855c69706 100644 --- a/include/xtensor/xexpression.hpp +++ b/include/xtensor/core/xexpression.hpp @@ -10,18 +10,18 @@ #ifndef XTENSOR_EXPRESSION_HPP #define XTENSOR_EXPRESSION_HPP -#include +#include #include -#include #include #include #include -#include "xlayout.hpp" -#include "xshape.hpp" -#include "xtensor_forward.hpp" -#include "xutils.hpp" +#include "../core/xiterator.hpp" +#include "../core/xlayout.hpp" +#include "../core/xshape.hpp" +#include "../core/xtensor_forward.hpp" +#include "../utils/xutils.hpp" namespace xt { @@ -168,7 +168,7 @@ namespace xt template