在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:xtensor-stack/xtensor-julia开源软件地址:https://github.com/xtensor-stack/xtensor-julia开源编程语言:C++ 78.4%开源软件介绍:Julia bindings for the xtensor C++ multi-dimensional array library.
The Julia bindings for DocumentationTo get started with using http://xtensor-julia.readthedocs.io/ Usagextensor-julia offers two container types wrapping julia arrays inplace to provide an xtensor semantics
Both containers enable the numpy-style APIs of xtensor (see the numpy to xtensor cheat sheet).
Example 1: Use an algorithm of the C++ standard library with Julia array.C++ code #include <numeric> // Standard library import for std::accumulate
#include <cxx_wrap.hpp> // libcxxwrap import to define Julia bindings
#include "xtensor-julia/jltensor.hpp" // Import the jltensor container definition
#include "xtensor/xmath.hpp" // xtensor import for the C++ universal functions
double sum_of_sines(xt::jltensor<double, 2> m)
{
auto sines = xt::sin(m); // sines does not actually hold values.
return std::accumulate(sines.cbegin(), sines.cend(), 0.0);
}
JLCXX_MODULE define_julia_module(jlcxx::Module& mod)
{
mod.method("sum_of_sines", sum_of_sines);
} Julia Code using xtensor_julia_test
arr = [[1.0 2.0]
[3.0 4.0]]
s = sum_of_sines(arr)
s Outputs
Example 2: Create a numpy-style universal function from a C++ scalar functionC++ code #include <cxx_wrap.hpp>
#include "xtensor-julia/jlvectorize.hpp"
double scalar_func(double i, double j)
{
return std::sin(i) - std::cos(j);
}
JLCXX_MODULE define_julia_module(jlcxx::Module& mod)
{
mod.method("vectorized_func", xt::jlvectorize(scalar_func));
} Julia Code using xtensor_julia_test
x = [[ 0.0 1.0 2.0 3.0 4.0]
[ 5.0 6.0 7.0 8.0 9.0]
[10.0 11.0 12.0 13.0 14.0]]
y = [1.0, 2.0, 3.0, 4.0, 5.0]
z = vectorized_func(x, y)
z Outputs
InstallationInstallation of the standalone C++ library
mamba install xtensor-julia -c conda-forge
cmake -D CMAKE_INSTALL_PREFIX=/prefix/path/
make
make install Installation of the Julia packageWe also provide a Julia package for xtensor, which has been packaged for both conda and Pkg (Julia's package manager). The repository for the Julia package is https://github.com/xtensor-stack/Xtensor.jl. To install the Julia package: using Pkg; Pkg.add("Xtensor"); The Julia available from the Julia package manager vendors the headers for Building the HTML Documentation
While doxygen must be installed separately, you can install breathe by typing pip install breathe Breathe can also be installed with conda install -c conda-forge breathe Finally, build the documentation with make html from the Running the tests
Dependencies on |
xtensor-julia |
xtensor |
libcxxwrap |
julia |
---|---|---|---|
master | ^0.24.0 | >=0.9,<0.10 | >=1.6.4,<2.0 |
0.10.2 | ^0.24.0 | >=0.0,<0.10 | >=1.6.4,<2.0 |
0.10.1 | ^0.24.0 | >=0.8.3,<0.9 | >=1.6.4,<2.0 |
0.10.0 | ^0.24.0 | >=0.8.3,<0.9 | >=1.6.4,<2.0 |
0.9.0 | ^0.21.2 | >=0.5.3,<0.6 | >=1.0.0,<1.1 |
These dependencies are automatically resolved when using the Julia package manager.
We use a shared copyright model that enables all contributors to maintain the copyright on their contributions.
This software is licensed under the BSD-3-Clause license. See the LICENSE file for details.
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论