The numerical backend provides high-performance linear algebra operations for quantum geometric computations. It supports multiple providers including:
- CPU (basic implementation)
- Apple Accelerate Framework
- OpenBLAS (planned)
- Intel MKL (planned)
The backend is organized into several layers:
- Basic complex number operations
- Vector/matrix operations
- Type conversions for different backends
- Platform-independent interface
- Unified interface to LAPACK operations
- Automatic provider selection
- Error handling and workspace management
- Support for different matrix layouts
numerical_backend_cpu.c: Basic CPU implementationnumerical_backend_accelerate.c: Apple Accelerate implementation- Future: OpenBLAS and MKL implementations
- Runtime backend selection
- Capability detection
- Performance metrics
- Error handling
// Initialize backend
numerical_config_t config = {
.type = NUMERICAL_BACKEND_CPU,
.max_threads = 4,
.use_fma = true
};
initialize_numerical_backend(&config);
// Perform operations
ComplexFloat a[4] = {{1,0}, {0,1}, {-1,0}, {0,-1}};
ComplexFloat b[4] = {{1,0}, {1,0}, {1,0}, {1,0}};
ComplexFloat c[4];
numerical_matrix_add(a, b, c, 2, 2);
// Clean up
shutdown_numerical_backend();All operations return a boolean success indicator and set an error code that can be retrieved:
numerical_error_t error = get_last_numerical_error();
const char* error_str = get_numerical_error_string(error);LAPACK operations are available through the wrapper interface:
// Perform SVD
ComplexFloat a[] = {...}; // Input matrix
ComplexFloat u[] = {...}; // Left singular vectors
float s[] = {...}; // Singular values
ComplexFloat vt[] = {...}; // Right singular vectors
lapack_svd(a, m, n, u, s, vt, LAPACK_ROW_MAJOR);-
Complete OpenBLAS Integration
- Add build system detection
- Implement type conversions
- Add performance benchmarks
-
Additional LAPACK Operations
- QR decomposition
- Eigendecomposition
- Cholesky decomposition
- LU factorization
-
Performance Optimizations
- Workspace reuse
- Thread pool integration
- Cache-aware algorithms
-
Testing
- Unit tests for all operations
- Performance regression tests
- Numerical stability tests
When adding new features:
- Update the appropriate interface header
- Implement for CPU backend first
- Add accelerated implementations
- Add tests and benchmarks
- Update documentation
- macOS: Full support (CPU + Accelerate)
- Linux: CPU support, OpenBLAS planned
- Windows: CPU support, MKL planned
- Matrix layout (row vs column major)
- Memory alignment
- Cache utilization
- Thread synchronization
- SIMD operations
NUMERICAL_SUCCESS: Operation completed successfullyNUMERICAL_ERROR_INVALID_ARGUMENT: Invalid input parametersNUMERICAL_ERROR_MEMORY: Memory allocation failedNUMERICAL_ERROR_BACKEND: Backend-specific errorNUMERICAL_ERROR_COMPUTATION: Computation failed to convergeNUMERICAL_ERROR_NOT_IMPLEMENTED: Operation not supported