SCTL is a header-only C++ library providing various functionalities for scientific computing. This documentation outlines these functionalities and provides a guide to getting started.
The only requirement to use SCTL is a working C++17 compliant compiler with OpenMP 4.0 support. It has been tested with GCC-9 and newer.
GCC 14 and newer on AArch64 (ARM, including Apple silicon): compile with -mearly-ra=none. GCC's early register allocator for vector registers can assign one register to two values in use at the same time, which gave wrong results in Vec at -O3 with GCC 14. GCC 15 and 16 have the same bug, hidden in the cases found so far. GCC 11 to 13 reject the flag.
To get started, download the latest version of SCTL from the SCTL GitHub.
git clone https://github.com/dmalhotra/SCTL.gitSince SCTL is a header-only library, it does not require compilation or installation. Simply include the sctl.hpp header file in your C++ project and start using the provided classes and functions.
#include <sctl.hpp>Ensure the compiler can locate the header file by providing the path to SCTL_ROOT/include using the flag -I ${SCTL_ROOT}/include.
The included Makefile builds the tests (make test). On Apple silicon with Homebrew: CPATH=/opt/homebrew/include LIBRARY_PATH=/opt/homebrew/lib make CXX=g++-15.
The following libraries can be optionally used when available. If not available, SCTL uses its own implementation which may be slower.
- BLAS: Enable by defining
SCTL_HAVE_BLAS. - LAPACK: Enable by defining
SCTL_HAVE_LAPACK. - libmvec: Enable by defining
SCTL_HAVE_LIBMVEC. - Intel SVML: Enable by defining
SCTL_HAVE_SVML. - MPI: Enable by defining
SCTL_HAVE_MPI(see Comm). - FFTW: Enable double precision by defining
SCTL_HAVE_FFTW, single precision by definingSCTL_HAVE_FFTWF, or long double precision by definingSCTL_HAVE_FFTWL(see FFT). - PVFMM: Enable by defining
SCTL_HAVE_PVFMM(requires MPI, see ParticleFMM). - LIBXSMM: Enable by defining
SCTL_HAVE_LIBXSMM, for small matrix products (see SmallGEMM).
To enable support for any of these libraries, define the corresponding flag during compilation. For example, to enable MPI support, use -DSCTL_HAVE_MPI.
The following compiler flags can be used to enable or disable specific features in SCTL:
-DSCTL_MEMDEBUG: Enable memory debugging (iterator.hpp, static-array.hpp).-DSCTL_GLOBAL_MEM_BUFF=<size in MB>: Use a global memory buffer for allocations.-DSCTL_PROFILE=<level>: Enable profiling.-DSCTL_VERBOSE: Enable verbose profiling output.-DSCTL_SIG_HANDLER: Enable stack trace. On Linux with glibc < 2.34, link with-ldl(newer glibc has it merged into libc).-DSCTL_QUAD_T=<type>: Enable support for quad-precision type, e.g.__float128on x86 and with GCC on Apple silicon.-DSCTL_BLAS_INT=<type>: Integer type of the BLAS and LAPACK interface,int(LP64) orint64_t(ILP64). By default it is detected from the linked BLAS on the first call; on big-endian systems it isintunless set.
The following list outlines the primary features and capabilities provided by the library, along with references to detailed tutorials and documentation for each component:
-
Basic Data Structures: Fundamental classes for storing and manipulating data.
- Vector: Dynamically allocated linear array.
- Matrix, Permutation: Dynamically allocated 2D array for matrix operations.
- Tensor: Statically allocated multi-dimensional array.
-
Numerical Solvers and Algorithms: Methods for solving equations, performing interpolations, numerical integration, and partitioning data.
- SDC (Spectral Deferred Correction): High-order solver for ordinary differential equations.
- GMRES solver, Krylov preconditioner: Distributed memory GMRES solver.
- LagrangeInterp: Polynomial interpolation and differentiation.
- ChebQuadRule, LegQuadRule: Clenshaw-Curtis and Gauss-Legendre quadrature rules.
- InterpQuadRule: Generating special quadrature rules.
- Tree, PtTree, Morton: Morton order based N-dimensional parallel tree structure.
- SortScatter: keys sorted into a rank-partitioned order, kept together with the permutation to and from the caller's order; the trees move particle data with it.
-
Spectral Methods: Methods for spectral representations and transformations.
- FFT: Wrapper for FFTW to perform fast Fourier transforms.
- SphericalHarmonics: Computing spherical harmonics.
-
Boundary Integral Methods: Techniques for solving partial differential equations using boundary integral representations.
- BoundaryIntegralOp: Generic class for instantiating layer-potential operators.
- Kernel functions: Contains a variety of kernel functions for integral equations.
- ParticleFMM: Integration with PVFMM for particle N-body calculations.
-
High Performance Computing (HPC): Tools for parallel and distributed computing.
- Comm: Wrapper for MPI to facilitate parallel computing.
- Vec: SIMD vectorization class for optimized computations.
- OpenMP utilities: Parallel algorithms such as merge-sort and scan using OpenMP.
- Profile: Tools for profiling and performance analysis.
-
Utilities: Miscellaneous utilities for data handling, debugging, and visualization.
- VTUData: Writes unstructured VTK files for data visualization.
- QuadReal, basic math functions: Quad-precision type and essential mathematical functions.
- Iterator, ConstIterator, StaticArray: Iterator and static array utilities.
- MemoryManager: Aligned memory allocation and deallocation.
- ScratchBuf, ScratchPool: Per-thread stack allocator for short-lived buffers in hot loops.
- Stacktrace utility: Prints stack traces for debugging.
- GEMM, SVD (unoptimized): Provides basic implementations of GEMM and SVD operations.
-
Experimental: Components whose interfaces may still change.
- GPUTree, PtTree: The
Tree/PtTreeinterface on a thrust backend, OpenMP host or CUDA device, with CUDA-aware MPI (make gpu).
- GPUTree, PtTree: The
-
Legacy (Unmaintained): Older functionalities that are no longer actively maintained.
- ChebBasis: Tensor product Chebyshev basis for general-dimension computations.
If you use SCTL, or code derived from it, please cite the software below (also listed in CITATION.cff):
- D. Malhotra, T. Li, R. Blackwell, A. Rahimian, W. Yan, X. Gao, SCTL: Scientific Computing Template Library, https://github.com/dmalhotra/SCTL, doi:10.5281/zenodo.23511629.
BibTeX
@software{sctl,
author = {Malhotra, Dhairya and Li, Tianyue and Blackwell, Robert and Rahimian, Abtin and Yan, Wen and Gao, Xuanzhao},
title = {{SCTL}: Scientific Computing Template Library},
url = {https://github.com/dmalhotra/SCTL},
doi = {10.5281/zenodo.23511629},
version = {2.1.0},
year = {2026}
}SCTL is licensed under the Apache License 2.0. The NOTICE file lists the authors and must be kept in any redistribution, including ports to other languages. It also has the authors' requests on crediting them and on AI use.