Debian Codegraph @

thirdparty/jolt_physics/Jolt/Math/DynMatrix.h

raw symbols SCIP
1 // Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2 // SPDX-FileCopyrightText: 2022 Jorrit Rouwe
3 // SPDX-License-Identifier: MIT
4
5 #pragma once
6
7 JPH_NAMESPACE_BEGIN
8
9 /// Dynamic resizable matrix class
10 class [[nodiscard]] DynMatrix
11 {
12 public:
13 /// Constructor
14 DynMatrix(const DynMatrix &) = default;
15 DynMatrix(uint inRows, uint inCols) : mRows(inRows), mCols(inCols) { mElements.resize(inRows * inCols); }
16
17 /// Access an element
18 float operator () (uint inRow, uint inCol) const { JPH_ASSERT(inRow < mRows && inCol < mCols); return mElements[inRow * mCols + inCol]; }
19 float & operator () (uint inRow, uint inCol) { JPH_ASSERT(inRow < mRows && inCol < mCols); return mElements[inRow * mCols + inCol]; }
20
21 /// Get dimensions
22 uint GetCols() const { return mCols; }
23 uint GetRows() const { return mRows; }
24
25 private:
26 uint mRows;
27 uint mCols;
28 Array<float> mElements;
29 };
30
31 JPH_NAMESPACE_END