This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
ojAlgo is a pure Java library for mathematics, linear algebra, and optimisation (LP, QP, MIP). Zero external dependencies. Targets Java 11+. Published to Maven Central as org.ojalgo:ojalgo.
./mvnw compile # Compile
./mvnw test # Run tests (excludes @Tag("slow"), @Tag("unstable"), @Tag("network"))
./mvnw test -Dtest=ClassName # Run a single test class
./mvnw test -Dtest=ClassName#methodName # Run a single test method
./mvnw package -DskipTests # Build JAR without testsAll source lives under org.ojalgo with these key packages:
structure— Foundational interfaces (Access1D/2D/AnyD,Mutate1D/2D,Structure1D/2D/AnyD,Factory1D/2D) that define how data is accessed, mutated, and structured. Nearly everything implements these.array— Concrete 1D array implementations: dense (ArrayR064,ArrayR032), sparse (SparseArray), off-heap (OffHeapR064), and buffer-backed. Naming convention:R064= double,R032= float,C128= complex,Q128= rational,H256= quaternion,Z0xx= integer types.matrix— Matrix types and operations:MatrixR064,MatrixR032,MatrixC128, etc. — user-facing immutable matrix typesstore/— mutable matrix storage (R064Store,GenericStore,SparseStore,RawStore) plus logical/virtual stores (transposed, conjugated, sliced, composed)decomposition/— LU, QR, Cholesky, SVD, Eigenvalue, LDL, Bidiagonal, Hessenberg, Tridiagonal with Dense/Raw/Sparse variantsoperation/— low-level BLAS-like primitives
optimisation— Mathematical programming:ExpressionsBasedModel— the primary modelling API (variables + expressions/constraints)linear/— Simplex solvers (primal, dual, phased, revised) with dense and sparse tableauxconvex/— QP solversinteger/— Branch-and-bound MIP solver
scalar— Number types:ComplexNumber,RationalNumber,Quaternion,Quadruple(double-double),BigScalarfunction— Mathematical functions, aggregators, constants (PrimitiveMath)concurrent— Threading utilities used internallydata— Data science utilities (clustering, ANN)
- Performance is paramount. Minimize allocations, prefer primitives over boxed types, avoid streams/Optionals in hot paths. Measure with JMH before/after.
- Use
TestUtils(not JUnitAssertions) for test assertions. Use tolerances for numeric comparisons. - Use
BasicLoggerfor diagnostic output, neverSystem.out/System.err. - No commented-out code. Use
TODOwith issue reference if needed. - Javadoc style: Keep tidy HTML, avoid unnecessary tags (
</p>,</li>,<b>,<i>), avoid HTML entities. Prefer Javadoc on declarations over inline comments. - Naming convention for array/matrix types: letter+digits encoding — R064=double, R032=float, C128=complex, Q128=rational, H256=quaternion, Z0xx=integer widths.
- Binary compatibility: Deprecate before removal. Keep changes small and focused.
- Ensure exactly one trailing newline in files.
- For optimisation work, compare with reference solvers (HiGHS, GLOP, CLP, SCIP, CBC, OSQP, CLARABEL).