C++ API reference¶
Note
This is the documentation for metatensor-core version
0.2.7. For other versions, look in the following pages:
Version 0.2
0.2.7
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
Version 0.1
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
Metatensor offers a C++ API, built on top of the C API. You
can the provided classes and functions in your own code by installing the
corresponding shared library and header, and then including
metatensor.hpp and linking with -lmetatensor. Alternatively, we provide
a cmake configuration file, allowing you to use metatensor like this
(after installation):
cmake_minimum_required(VERSION 3.22)
project(my-project CXX)
find_package(metatensor)
# add executables/libraries
add_executable(my-exe exe-source.cpp)
add_library(my-lib lib-source.cpp)
# Link to metatensor, this makes the header accessible and link to the right
# libraries.
#
# The `metatensor` target will be an alias for `metatensor::shared`
# or `metatensor::static` depending how you've installed the code.
target_link_libraries(my-exe metatensor)
target_link_libraries(my-lib metatensor)
# alternatively, you can explicitly use the static or shared build of
# metatensor. Unless you have a very specific need for a static build, we
# recommend using the shared version of metatensor: this will allow you to
# pass data from your code to other codes which use the same metatensor
# shared library.
# target_link_libraries(my-exe metatensor::shared)
# target_link_libraries(my-exe metatensor::static)
The functions and types provided in metatensor.hpp can be grouped as follow: