TCI (Tensor Computing Interface) is a universal C++ interface for tensor computing libraries. This repository provides the Cytnx backend implementation, allowing TCI APIs to work with the Cytnx tensor library.
- Public API: C++17 compatible — no C++20 features leak into user-facing headers
- TCI build: C++20 (required by Cytnx headers)
- CMake 3.24+: Required for Cytnx
- C++20 capable compiler: GCC 10+, Clang 12+
- BLAS/LAPACK: OpenBLAS recommended
- Cytnx: Included as git submodule
- OpenMP: For parallel computations
- CUDA: For GPU acceleration (via Cytnx)
git clone --recursive https://github.com/r-ccs-cms/tensor-computing-interface-backend-cytnx.git
cd tensor-computing-interface-backend-cytnxbrew install openblas llvm libomp cmake boost arpack ninjallvm (LLVM Clang) is optional; Apple Clang may work.
module load intel/oneapi # Provides icx, icpx, ifort, and MKL
module load boost # Required by CytnxARPACK-NG will be automatically built from source if not found. To use a pre-built ARPACK, set ARPACK_ROOT or pass -DARPACK_ROOT=/path/to/arpack.
macOS with Homebrew:
cmake --preset brew-debug
cmake --build --preset brew-debug
ctest --preset brew-debugLinux with Intel oneAPI:
module load intel/oneapi boost
cmake --preset intel-debug
cmake --build --preset intel-debug
ctest --preset intel-debugReplace debug with release for optimized builds.
cmake -S . -B build \
-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/macos-homebrew.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_STANDARD=20 \
-DBUILD_PYTHON=OFF \
-DTCI_BUILD_TESTS=ON
cmake --build build --parallel 8# All tests
./build-debug/test/TCITests
# Specific test cases
./build-debug/test/TCITests --test-case="*template*"Define TCI_NO_DEPRECATED_API to suppress deprecated template <typename ElemT> overloads:
#define TCI_NO_DEPRECATED_API
#include "tci/tci.h"Or via CMake:
target_compile_definitions(your_target PRIVATE TCI_NO_DEPRECATED_API)#include "tci/tci.h"
int main() {
using Tensor = tci::CytnxTensor<cytnx::cytnx_complex128>;
tci::context_handle_t<Tensor> ctx;
tci::create_context(ctx);
Tensor a = tci::zeros<Tensor>(ctx, {3, 4});
Tensor b = tci::eye<Tensor>(ctx, 3);
Tensor c;
tci::copy(ctx, a, c);
auto norm_val = tci::norm(ctx, b);
tci::show(ctx, b);
tci::destroy_context(ctx);
return 0;
}#include "tci/tci.h"
int main() {
using Tensor = tci::CytnxTensor<cytnx::cytnx_complex128>;
using Elem = tci::elem_t<Tensor>; // std::complex<double>
tci::context_handle_t<Tensor> ctx;
tci::create_context(ctx);
Tensor tensor;
tci::allocate(ctx, {100, 100}, tensor);
tci::for_each(ctx, tensor, [](Elem& elem) {
elem = std::sqrt(elem) * 2.0;
elem = elem / std::abs(elem);
});
tci::destroy_context(ctx);
return 0;
}CytnxTensor<ElemT>fixes the element type at compile time, sotci::elem_t<Tensor>resolves toElemTand supports direct arithmetic.- The wrapper exposes the underlying Cytnx tensor via
Tensor::backendwhen lower-level Cytnx APIs are required.
g++ -std=c++17 -I<tci-install>/include your_code.cpp -lTCI -lcytnx# Requires Doxygen and uv
cmake -S documentation -B build/doc
cmake --build build/doc --target GenerateDocs
open build/doc/doxygen/html/index.html