How petewebbo/momath works
Main Components
• Math Core Modules:
• Vector Module (src/vector)
• Contains dynamic/static vector implementations and vector operations (mo_vector.hpp, mo_vector_ops.hpp).
• Matrix Module (src/matrix)
• Provides matrix implementations (static/dynamic), matrix operations, and higher-level linear algebra operations using OpenBLAS (files like mo_matrix.hpp, mo_matrix_ops.hpp).
• Types Module (src/types)
• Defines basic and specialized types for DSP, FFT, matrix, and vector operations.
• FFT Engine (src/fft)
• Acts as a unified interface (mo_fft.hpp) to different FFT implementations.
• Contains submodules for each FFT library:
• FFTW (src/fft/fftw)
• NE10 (src/fft/ne10)
• PocketFFT (src/fft/pocket)
• Splitradix (src/fft/splitradix)
• Utility Module (src/util)
• Provides general utility functions (assertions, file IO, math utilities, printing) to support common operations across modules.
• Error Handling
• Managed via a dedicated header (src/mo_errors.hpp) to capture error definitions and handling, ensuring robustness.
Relationships and Interactions Between Components
• The Vector and Matrix modules both use the Types module for consistent type definitions.
• The FFT module is designed with multiple strategies – the library selected depends on compile-time flags. Therefore, the system design should denote an abstraction layer where a generic FFT interface is provided, while concrete implementations (ne10, fftw, pocket, splitradix) are interchangeable.
• The Matrix module interfaces with the OpenBLAS-based linear algebra routines (under src/matrix/linalg/openblas) for operations such as matrix multiplication and SVD.
• Utility functions form a cross-cutting layer that supports all modules, e.g., for debugging, assertions, and file I/O.
• There is a test suite organized in the test directory that validates each of these functional areas (FFT, matrix, vector).
Architectural Patterns and Design Principles
• Modularity: Each mathematical operation domain (vector, matrix, FFT) is compartmentalized for ease of maintenance and extension.
• Abstraction and Strategy: Especially in the FFT Engine – a single interface (mo_fft.hpp) allows multiple underlying implementations to be swapped via build-time flags.
• Separation of Concerns: Distinguishing between core math functionality, utility functions, and external library interactions (such as OpenBLAS) keeps the design clear and testable.
Instructed Elements
• Clear labels for each component (e.g., “Vector Module”, “Matrix Module”, “FFT Engine – Splitradix”, “FFT Engine – FFTW”, “Types”, “Utility”, “Linear Algebra via OpenBLAS”).
• Data flows from the FFT abstract interface to its specific implementations.
• Dependencies, such as the Matrix module relying on the Types and OpenBLAS modules.
• Interactions where utility functions support the main modules.
• Core logic components (Vector, Matrix, FFT)
• Supporting/shared modules (Types, Util, Error Handling)
• External dependencies (OpenBLAS)
• Build configuration/strategy (highlighting the use of CMake flags for selecting FFT libraries)