7#include <initializer_list>
32template <
typename Scalar_>
54 m_storage.emplace_back();
66 m_storage.emplace_back(
nullptr);
78 if (list.size() > 0) {
79 m_cols = list.begin()->size();
84 const auto&
row : list) {
89 for (
const auto&
row : list) {
90 std::ranges::copy(
row, std::back_inserter(m_storage));
102 m_rows = list.size();
104 if (list.size() > 0) {
105 m_cols = list.begin()->size();
109 for ([[maybe_unused]]
110 const auto&
row : list) {
115 for (
const auto&
row : list) {
116 std::ranges::copy(
row, std::back_inserter(m_storage));
128 m_rows = list.size();
130 if (list.size() > 0) {
131 m_cols = list.begin()->size();
135 for ([[maybe_unused]]
136 const auto&
row : list) {
141 for (
const auto&
row : list) {
142 std::ranges::copy(
row, std::back_inserter(m_storage));
149 template <
typename Derived>
152 : m_rows{static_cast<int>(values.
rows())},
153 m_cols{static_cast<int>(values.
cols())} {
154 m_storage.reserve(values.rows() * values.cols());
155 for (
int row = 0;
row < values.rows(); ++
row) {
156 for (
int col = 0;
col < values.cols(); ++
col) {
157 m_storage.emplace_back(values(
row,
col));
165 template <
typename Derived>
168 : m_rows{static_cast<int>(values.
rows())},
169 m_cols{static_cast<int>(values.
cols())} {
170 m_storage.reserve(values.rows() * values.cols());
171 for (
int row = 0;
row < values.rows(); ++
row) {
172 for (
int col = 0;
col < values.cols(); ++
col) {
174 m_storage.emplace_back(values.diagonal()[
row]);
176 m_storage.emplace_back(
Scalar(0));
187 m_storage.emplace_back(variable);
195 m_storage.emplace_back(std::move(variable));
203 : m_rows{values.
rows()}, m_cols{values.
cols()} {
207 m_storage.emplace_back(values(
row,
col));
217 : m_rows{values.
rows()}, m_cols{values.
cols()} {
221 m_storage.emplace_back(values(
row,
col));
230 : m_rows{static_cast<int>(values.
size())}, m_cols{1} {
234 m_storage.emplace_back(values[
row *
cols() +
col]);
250 m_storage.emplace_back(values[
row *
cols +
col]);
259 template <
typename Derived>
263 for (
int row = 0;
row < values.rows(); ++
row) {
264 for (
int col = 0;
col < values.cols(); ++
col) {
281 (*this)(0, 0) =
value;
289 template <
typename Derived>
290 requires std::same_as<typename Derived::Scalar, Scalar>
291 void set_value(
const Eigen::MatrixBase<Derived>& values) {
294 for (
int row = 0;
row < values.rows(); ++
row) {
295 for (
int col = 0;
col < values.cols(); ++
col) {
329 return m_storage[
index];
338 return m_storage[
index];
349 int block_rows,
int block_cols) {
354 return VariableBlock{*
this, row_offset, col_offset, block_rows, block_cols};
367 int block_cols)
const {
372 return VariableBlock{*
this, row_offset, col_offset, block_rows, block_cols};
381 int row_slice_length = row_slice.
adjust(
rows());
382 int col_slice_length = col_slice.
adjust(
cols());
383 return VariableBlock{*
this, std::move(row_slice), row_slice_length,
384 std::move(col_slice), col_slice_length};
393 Slice col_slice)
const {
394 int row_slice_length = row_slice.
adjust(
rows());
395 int col_slice_length = col_slice.
adjust(
cols());
396 return VariableBlock{*
this, std::move(row_slice), row_slice_length,
397 std::move(col_slice), col_slice_length};
411 int row_slice_length,
413 int col_slice_length) {
414 return VariableBlock{*
this, std::move(row_slice), row_slice_length,
415 std::move(col_slice), col_slice_length};
429 Slice row_slice,
int row_slice_length,
Slice col_slice,
430 int col_slice_length)
const {
431 return VariableBlock{*
this, std::move(row_slice), row_slice_length,
432 std::move(col_slice), col_slice_length};
444 return block(offset, 0, length, 1);
457 return block(offset, 0, length, 1);
500 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
507#pragma GCC diagnostic push
508#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
510 for (
int i = 0; i < lhs.rows(); ++i) {
511 for (
int j = 0; j < rhs.cols(); ++j) {
513 for (
int k = 0; k < lhs.cols(); ++k) {
514 sum += lhs(i, k) * rhs(k, j);
527 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
533 for (
int i = 0; i < lhs.rows(); ++i) {
534 for (
int j = 0; j < rhs.cols(); ++j) {
536 for (
int k = 0; k < lhs.cols(); ++k) {
537 sum += lhs(i, k) * rhs(k, j);
550 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
556 for (
int i = 0; i < lhs.rows(); ++i) {
557 for (
int j = 0; j < rhs.cols(); ++j) {
559 for (
int k = 0; k < lhs.cols(); ++k) {
560 sum += lhs(i, k) * rhs(k, j);
566#pragma GCC diagnostic pop
576 template <EigenMatrixLike LHS>
594 template <SleipnirMatrixLike<Scalar> LHS, ScalarLike RHS>
611 template <EigenMatrixLike RHS>
629 template <ScalarLike LHS, SleipnirMatrixLike<Scalar> RHS>
649 for (
int i = 0; i <
rows(); ++i) {
650 for (
int j = 0; j < rhs.cols(); ++j) {
652 for (
int k = 0; k <
cols(); ++k) {
653 sum += (*this)(i, k) * rhs(k, j);
668 for (
int col = 0;
col < rhs.cols(); ++
col) {
681 template <EigenMatrixLike LHS>
700 template <SleipnirMatrixLike<Scalar> LHS, ScalarLike RHS>
719 template <SleipnirMatrixLike<Scalar> LHS>
752 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
754 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
772 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
774 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
792 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
794 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
844 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
846 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
864 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
866 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
884 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
886 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
951 return (*
this)(0, 0);
972 int rows()
const {
return m_rows; }
977 int cols()
const {
return m_cols; }
995 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
value() {
996 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic> result{
rows(),
1026#ifndef DOXYGEN_SHOULD_SKIP_THIS
1192 size_t size()
const {
return m_storage.size(); }
1202 for (
auto& elem : result) {
1217 for (
auto& elem : result) {
1233 for (
auto& elem : result) {
1246template <
typename Derived>
1250template <
typename Derived>
1260template <
typename Scalar>
1270 for (
int row = 0; row < lhs.
rows(); ++row) {
1271 for (
int col = 0; col < lhs.
cols(); ++col) {
1272 result(row, col) = binary_op(lhs(row, col), rhs(row, col));
1288template <
typename Scalar>
1294 for (
const auto& row : list) {
1295 if (row.size() > 0) {
1296 rows += row.begin()->rows();
1300 int latest_cols = 0;
1301 for (
const auto& elem : row) {
1303 slp_assert(row.begin()->rows() == elem.rows());
1305 latest_cols += elem.cols();
1320 for (
const auto& row : list) {
1322 for (
const auto& elem : row) {
1323 result.
block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1324 col_offset += elem.cols();
1326 if (row.size() > 0) {
1327 row_offset += row.begin()->rows();
1345template <
typename Scalar>
1351 for (
const auto& row : list) {
1352 if (row.size() > 0) {
1353 rows += row.begin()->rows();
1357 int latest_cols = 0;
1358 for (
const auto& elem : row) {
1360 slp_assert(row.begin()->rows() == elem.rows());
1362 latest_cols += elem.cols();
1377 for (
const auto& row : list) {
1379 for (
const auto& elem : row) {
1380 result.
block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1381 col_offset += elem.cols();
1383 if (row.size() > 0) {
1384 row_offset += row.begin()->rows();
1397template <
typename Scalar>
1403 if (A.
rows() == 1 && A.
cols() == 1) {
1405 return B(0, 0) / A(0, 0);
1406 }
else if (A.
rows() == 2 && A.
cols() == 2) {
1412 const auto& a = A(0, 0);
1413 const auto& b = A(0, 1);
1414 const auto& c = A(1, 0);
1415 const auto& d = A(1, 1);
1418 auto det_A = a * d - b * c;
1419 return adj_A / det_A * B;
1420 }
else if (A.
rows() == 3 && A.
cols() == 3) {
1432 const auto& a = A(0, 0);
1433 const auto& b = A(0, 1);
1434 const auto& c = A(0, 2);
1435 const auto& d = A(1, 0);
1436 const auto& e = A(1, 1);
1437 const auto& f = A(1, 2);
1438 const auto& g = A(2, 0);
1439 const auto& h = A(2, 1);
1440 const auto& i = A(2, 2);
1461 auto adj_A00 = ei - fh;
1462 auto adj_A10 =
fg - di;
1463 auto adj_A20 = dh - eg;
1466 {adj_A10, ai - cg, cd - af},
1467 {adj_A20,
bg - ah, ae - bd}};
1468 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20;
1469 return adj_A / det_A * B;
1470 }
else if (A.
rows() == 4 && A.
cols() == 4) {
1480 const auto& a = A(0, 0);
1481 const auto& b = A(0, 1);
1482 const auto& c = A(0, 2);
1483 const auto& d = A(0, 3);
1484 const auto& e = A(1, 0);
1485 const auto& f = A(1, 1);
1486 const auto& g = A(1, 2);
1487 const auto& h = A(1, 3);
1488 const auto& i = A(2, 0);
1489 const auto& j = A(2, 1);
1490 const auto& k = A(2, 2);
1491 const auto& l = A(2, 3);
1492 const auto& m = A(3, 0);
1493 const auto& n = A(3, 1);
1494 const auto& o = A(3, 2);
1495 const auto&
p = A(3, 3);
1497 auto afk = a * f * k;
1498 auto afl = a * f * l;
1499 auto afo = a * f * o;
1500 auto afp = a * f *
p;
1501 auto agj = a * g * j;
1502 auto agl = a * g * l;
1503 auto agn = a * g * n;
1504 auto agp = a * g *
p;
1505 auto ahj = a * h * j;
1506 auto ahk = a * h * k;
1507 auto ahn = a * h * n;
1508 auto aho = a * h * o;
1509 auto ajo = a * j * o;
1510 auto ajp = a * j *
p;
1511 auto akn = a * k * n;
1512 auto akp = a * k *
p;
1513 auto aln = a * l * n;
1514 auto alo = a * l * o;
1515 auto bek = b * e * k;
1516 auto bel = b * e * l;
1517 auto beo = b * e * o;
1518 auto bep = b * e *
p;
1519 auto bgi = b * g * i;
1520 auto bgl = b * g * l;
1521 auto bgm = b * g * m;
1522 auto bgp = b * g *
p;
1523 auto bhi = b * h * i;
1524 auto bhk = b * h * k;
1525 auto bhm = b * h * m;
1526 auto bho = b * h * o;
1527 auto bio = b * i * o;
1528 auto bip = b * i *
p;
1529 auto bjp = b * j *
p;
1530 auto bkm = b * k * m;
1531 auto bkp = b * k *
p;
1532 auto blm = b * l * m;
1533 auto blo = b * l * o;
1534 auto cej = c * e * j;
1535 auto cel = c * e * l;
1536 auto cen = c * e * n;
1537 auto cep = c * e *
p;
1538 auto cfi = c * f * i;
1539 auto cfl = c * f * l;
1540 auto cfm = c * f * m;
1541 auto cfp = c * f *
p;
1542 auto chi = c * h * i;
1543 auto chj = c * h * j;
1544 auto chm = c * h * m;
1545 auto chn = c * h * n;
1546 auto cin = c * i * n;
1547 auto cip = c * i *
p;
1548 auto cjm = c * j * m;
1549 auto cjp = c * j *
p;
1550 auto clm = c * l * m;
1551 auto cln = c * l * n;
1552 auto dej = d * e * j;
1553 auto dek = d * e * k;
1554 auto den = d * e * n;
1555 auto deo = d * e * o;
1556 auto dfi = d * f * i;
1557 auto dfk = d * f * k;
1558 auto dfm = d * f * m;
1559 auto dfo = d * f * o;
1560 auto dgi = d * g * i;
1561 auto dgj = d * g * j;
1562 auto dgm = d * g * m;
1563 auto dgn = d * g * n;
1564 auto din = d * i * n;
1565 auto dio = d * i * o;
1566 auto djm = d * j * m;
1567 auto djo = d * j * o;
1568 auto dkm = d * k * m;
1569 auto dkn = d * k * n;
1570 auto ejo = e * j * o;
1571 auto ejp = e * j *
p;
1572 auto ekn = e * k * n;
1573 auto ekp = e * k *
p;
1574 auto eln = e * l * n;
1575 auto elo = e * l * o;
1576 auto fio = f * i * o;
1577 auto fip = f * i *
p;
1578 auto fkm = f * k * m;
1579 auto fkp = f * k *
p;
1580 auto flm = f * l * m;
1581 auto flo = f * l * o;
1582 auto gin = g * i * n;
1583 auto gip = g * i *
p;
1584 auto gjm = g * j * m;
1585 auto gjp = g * j *
p;
1586 auto glm = g * l * m;
1587 auto gln = g * l * n;
1588 auto hin = h * i * n;
1589 auto hio = h * i * o;
1590 auto hjm = h * j * m;
1591 auto hjo = h * j * o;
1592 auto hkm = h * k * m;
1593 auto hkn = h * k * n;
1595 auto adj_A00 = fkp - flo - gjp + gln + hjo - hkn;
1596 auto adj_A01 = -bkp + blo + cjp - cln - djo + dkn;
1597 auto adj_A02 = bgp - bho - cfp + chn + dfo - dgn;
1598 auto adj_A03 = -bgl + bhk + cfl - chj - dfk + dgj;
1599 auto adj_A10 = -ekp + elo + gip - glm - hio + hkm;
1600 auto adj_A11 = akp - alo - cip + clm + dio - dkm;
1601 auto adj_A12 = -agp + aho + cep - chm - deo + dgm;
1602 auto adj_A13 = agl - ahk - cel + chi + dek - dgi;
1603 auto adj_A20 = ejp - eln - fip + flm + hin - hjm;
1604 auto adj_A21 = -ajp + aln + bip - blm - din + djm;
1605 auto adj_A22 = afp - ahn - bep + bhm + den - dfm;
1606 auto adj_A23 = -afl + ahj + bel - bhi - dej + dfi;
1607 auto adj_A30 = -ejo + ekn + fio - fkm - gin + gjm;
1609 auto adj_A31 = ajo - akn - bio + bkm + cin - cjm;
1610 auto adj_A32 = -afo + agn + beo - bgm - cen + cfm;
1611 auto adj_A33 = afk - agj - bek + bgi + cej - cfi;
1614 {adj_A10, adj_A11, adj_A12, adj_A13},
1615 {adj_A20, adj_A21, adj_A22, adj_A23},
1616 {adj_A30, adj_A31, adj_A32, adj_A33}};
1617 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20 + d * adj_A30;
1618 return adj_A / det_A * B;
1621 Eigen::Matrix<Variable<Scalar>, Eigen::Dynamic, Eigen::Dynamic>;
1623 MatrixXv eigen_A{A.
rows(), A.
cols()};
1624 for (
int row = 0; row < A.
rows(); ++row) {
1625 for (
int col = 0; col < A.
cols(); ++col) {
1626 eigen_A(row, col) = A(row, col);
1630 MatrixXv eigen_B{B.rows(), B.cols()};
1631 for (
int row = 0; row < B.rows(); ++row) {
1632 for (
int col = 0; col < B.cols(); ++col) {
1633 eigen_B(row, col) = B(row, col);
1637 MatrixXv eigen_X = eigen_A.householderQr().solve(eigen_B);
1640 for (
int row = 0; row < X.
rows(); ++row) {
1641 for (
int col = 0; col < X.
cols(); ++col) {
1642 X(row, col) = eigen_X(row, col);
#define slp_assert(condition)
Aborts in C++.
Definition assert.hpp:25
@ index
Definition base.h:690
Marker interface for concepts to determine whether a given scalar or matrix type belongs to Sleipnir.
Definition sleipnir_base.hpp:9
Represents a sequence of elements in an iterable object.
Definition slice.hpp:25
constexpr int adjust(int length)
Adjusts start and end slice indices assuming a sequence of the specified length.
Definition slice.hpp:118
A submatrix of autodiff variables with reference semantics.
Definition variable_block.hpp:24
An autodiff variable pointing to an expression node.
Definition variable.hpp:47
Definition variable_matrix.hpp:1072
constexpr const_iterator() noexcept=default
const Variable< Scalar > & const_reference
Definition variable_matrix.hpp:1078
constexpr const_reference operator*() const noexcept
Definition variable_matrix.hpp:1110
constexpr const_iterator & operator--() noexcept
Definition variable_matrix.hpp:1097
std::bidirectional_iterator_tag iterator_category
Definition variable_matrix.hpp:1074
constexpr const_iterator operator++(int) noexcept
Definition variable_matrix.hpp:1091
constexpr bool operator==(const const_iterator &) const noexcept=default
std::ptrdiff_t difference_type
Definition variable_matrix.hpp:1076
constexpr const_iterator operator--(int) noexcept
Definition variable_matrix.hpp:1102
Variable< Scalar > * pointer
Definition variable_matrix.hpp:1077
Variable< Scalar > value_type
Definition variable_matrix.hpp:1075
constexpr const_iterator & operator++() noexcept
Definition variable_matrix.hpp:1086
Definition variable_matrix.hpp:1028
constexpr iterator & operator++() noexcept
Definition variable_matrix.hpp:1042
std::ptrdiff_t difference_type
Definition variable_matrix.hpp:1032
Variable< Scalar > value_type
Definition variable_matrix.hpp:1031
constexpr iterator & operator--() noexcept
Definition variable_matrix.hpp:1053
constexpr iterator operator--(int) noexcept
Definition variable_matrix.hpp:1058
std::bidirectional_iterator_tag iterator_category
Definition variable_matrix.hpp:1030
Variable< Scalar > & reference
Definition variable_matrix.hpp:1034
constexpr reference operator*() const noexcept
Definition variable_matrix.hpp:1066
constexpr iterator() noexcept=default
constexpr bool operator==(const iterator &) const noexcept=default
Variable< Scalar > * pointer
Definition variable_matrix.hpp:1033
constexpr iterator operator++(int) noexcept
Definition variable_matrix.hpp:1047
A matrix of autodiff variables.
Definition variable_matrix.hpp:33
const_reverse_iterator crbegin() const
Returns const reverse begin iterator.
Definition variable_matrix.hpp:1178
VariableMatrix(std::initializer_list< std::initializer_list< Variable< Scalar > > > list)
Constructs a scalar VariableMatrix from a nested list of Variables.
Definition variable_matrix.hpp:73
const_reverse_iterator crend() const
Returns const reverse end iterator.
Definition variable_matrix.hpp:1185
Scalar_ Scalar
Scalar type alias.
Definition variable_matrix.hpp:36
const VariableBlock< const VariableMatrix > operator()(Slice row_slice, Slice col_slice) const
Returns a slice of the variable matrix.
Definition variable_matrix.hpp:392
iterator end()
Returns end iterator.
Definition variable_matrix.hpp:1129
VariableMatrix(Variable< Scalar > &&variable)
Constructs a scalar VariableMatrix from a Variable.
Definition variable_matrix.hpp:194
const VariableBlock< const VariableMatrix > block(int row_offset, int col_offset, int block_rows, int block_cols) const
Returns a block of the variable matrix.
Definition variable_matrix.hpp:364
size_t size() const
Returns number of elements in matrix.
Definition variable_matrix.hpp:1192
static VariableMatrix< Scalar > zero(int rows, int cols)
Returns a variable matrix filled with zeroes.
Definition variable_matrix.hpp:1199
VariableBlock< VariableMatrix > block(int row_offset, int col_offset, int block_rows, int block_cols)
Returns a block of the variable matrix.
Definition variable_matrix.hpp:348
VariableMatrix(const std::vector< std::vector< Scalar > > &list)
Constructs a scalar VariableMatrix from a nested list of scalars.
Definition variable_matrix.hpp:100
VariableMatrix & operator=(ScalarLike auto value)
Assigns a scalar to the matrix.
Definition variable_matrix.hpp:278
VariableMatrix & operator-=(const MatrixLike auto &rhs)
Compound subtraction-assignment operator.
Definition variable_matrix.hpp:903
Variable< Scalar > & operator[](int index)
Returns the element at the given index.
Definition variable_matrix.hpp:327
VariableMatrix & operator=(const Eigen::MatrixBase< Derived > &values)
Assigns an Eigen matrix to a VariableMatrix.
Definition variable_matrix.hpp:260
friend VariableMatrix< Scalar > operator-(const LHS &lhs, const RHS &rhs)
Binary subtraction operator.
Definition variable_matrix.hpp:845
VariableMatrix & operator-=(const ScalarLike auto &rhs)
Compound subtraction-assignment operator.
Definition variable_matrix.hpp:919
friend VariableMatrix< Scalar > operator*(const Variable< Scalar > &lhs, const RHS &rhs)
Scalar-matrix multiplication operator.
Definition variable_matrix.hpp:612
VariableMatrix & operator*=(const ScalarLike auto &rhs)
Compound matrix-scalar multiplication-assignment operator.
Definition variable_matrix.hpp:666
Scalar value(int index)
Returns an element of the variable matrix.
Definition variable_matrix.hpp:990
VariableMatrix(const VariableBlock< VariableMatrix > &values)
Constructs a VariableMatrix from a VariableBlock.
Definition variable_matrix.hpp:202
VariableBlock< VariableMatrix > operator()(Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length)
Returns a slice of the variable matrix.
Definition variable_matrix.hpp:410
VariableMatrix(int rows, int cols)
Constructs a zero-initialized VariableMatrix with the given dimensions.
Definition variable_matrix.hpp:51
const_iterator cbegin() const
Returns const begin iterator.
Definition variable_matrix.hpp:1144
const_iterator begin() const
Returns const begin iterator.
Definition variable_matrix.hpp:1134
const_iterator cend() const
Returns const end iterator.
Definition variable_matrix.hpp:1149
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > value()
Returns the contents of the variable matrix.
Definition variable_matrix.hpp:995
friend VariableMatrix< Scalar > operator/(const LHS &lhs, const Variable< Scalar > &rhs)
Binary division operator.
Definition variable_matrix.hpp:682
VariableMatrix(int rows)
Constructs a zero-initialized VariableMatrix column vector with the given rows.
Definition variable_matrix.hpp:45
const VariableBlock< const VariableMatrix > operator()(Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length) const
Returns a slice of the variable matrix.
Definition variable_matrix.hpp:428
const Variable< Scalar > & operator()(int row, int col) const
Returns the element at the given row and column.
Definition variable_matrix.hpp:317
VariableMatrix(std::span< const Variable< Scalar > > values, int rows, int cols)
Constructs a matrix wrapper around a Variable array.
Definition variable_matrix.hpp:244
VariableBlock< VariableMatrix > col(int col)
Returns a column slice of the variable matrix.
Definition variable_matrix.hpp:482
VariableMatrix(const Eigen::MatrixBase< Derived > &values)
Constructs a VariableMatrix from an Eigen matrix.
Definition variable_matrix.hpp:151
Variable< Scalar > & operator()(int row, int col)
Returns the element at the given row and column.
Definition variable_matrix.hpp:306
const VariableBlock< const VariableMatrix > col(int col) const
Returns a column slice of the variable matrix.
Definition variable_matrix.hpp:491
VariableMatrix & operator+=(const ScalarLike auto &rhs)
Compound addition-assignment operator.
Definition variable_matrix.hpp:827
friend VariableMatrix< Scalar > operator*(const LHS &lhs, const Variable< Scalar > &rhs)
Matrix-scalar multiplication operator.
Definition variable_matrix.hpp:577
VariableBlock< VariableMatrix > segment(int offset, int length)
Returns a segment of the variable vector.
Definition variable_matrix.hpp:440
std::reverse_iterator< iterator > reverse_iterator
Definition variable_matrix.hpp:1116
Scalar value(int row, int col)
Returns an element of the variable matrix.
Definition variable_matrix.hpp:984
const VariableBlock< const VariableMatrix > row(int row) const
Returns a row slice of the variable matrix.
Definition variable_matrix.hpp:473
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition variable_matrix.hpp:1117
VariableMatrix()=default
Constructs an empty VariableMatrix.
VariableMatrix & operator+=(const MatrixLike auto &rhs)
Compound addition-assignment operator.
Definition variable_matrix.hpp:811
VariableMatrix(std::span< const Variable< Scalar > > values)
Constructs a column vector wrapper around a Variable array.
Definition variable_matrix.hpp:229
friend VariableMatrix< Scalar > operator-(const SleipnirMatrixLike< Scalar > auto &lhs)
Unary minus operator.
Definition variable_matrix.hpp:934
static VariableMatrix< Scalar > constant(int rows, int cols, Scalar constant)
Returns a variable matrix filled with a constant.
Definition variable_matrix.hpp:1230
VariableMatrix< Scalar > T() const
Returns the transpose of the variable matrix.
Definition variable_matrix.hpp:957
VariableMatrix< Scalar > cwise_transform(function_ref< Variable< Scalar >(const Variable< Scalar > &x)> unary_op) const
Transforms the matrix coefficient-wise with an unary operator.
Definition variable_matrix.hpp:1012
friend VariableMatrix< Scalar > operator*(const LHS &lhs, const RHS &rhs)
Matrix multiplication operator.
Definition variable_matrix.hpp:501
VariableBlock< VariableMatrix > operator()(Slice row_slice, Slice col_slice)
Returns a slice of the variable matrix.
Definition variable_matrix.hpp:380
const_reverse_iterator rbegin() const
Returns const reverse begin iterator.
Definition variable_matrix.hpp:1164
VariableMatrix(const Variable< Scalar > &variable)
Constructs a scalar VariableMatrix from a Variable.
Definition variable_matrix.hpp:186
reverse_iterator rend()
Returns reverse end iterator.
Definition variable_matrix.hpp:1159
VariableMatrix(const VariableBlock< const VariableMatrix > &values)
Constructs a VariableMatrix from a VariableBlock.
Definition variable_matrix.hpp:216
int rows() const
Returns the number of rows in the matrix.
Definition variable_matrix.hpp:972
static VariableMatrix< Scalar > one(int rows, int cols)
Returns a variable matrix filled with ones.
Definition variable_matrix.hpp:1214
VariableMatrix(const Eigen::DiagonalBase< Derived > &values)
Constructs a VariableMatrix from an Eigen diagonal matrix.
Definition variable_matrix.hpp:167
const_reverse_iterator rend() const
Returns const reverse end iterator.
Definition variable_matrix.hpp:1171
VariableMatrix & operator*=(const MatrixLike auto &rhs)
Compound matrix multiplication-assignment operator.
Definition variable_matrix.hpp:646
VariableMatrix(detail::empty_t, int rows, int cols)
Constructs an empty VariableMatrix with the given dimensions.
Definition variable_matrix.hpp:62
const_iterator end() const
Returns const end iterator.
Definition variable_matrix.hpp:1139
void set_value(const Eigen::MatrixBase< Derived > &values)
Sets the VariableMatrix's internal values.
Definition variable_matrix.hpp:291
iterator begin()
Returns begin iterator.
Definition variable_matrix.hpp:1124
const VariableBlock< const VariableMatrix > segment(int offset, int length) const
Returns a segment of the variable vector.
Definition variable_matrix.hpp:452
reverse_iterator rbegin()
Returns reverse begin iterator.
Definition variable_matrix.hpp:1154
VariableBlock< VariableMatrix > row(int row)
Returns a row slice of the variable matrix.
Definition variable_matrix.hpp:464
friend VariableMatrix< Scalar > operator+(const LHS &lhs, const RHS &rhs)
Binary addition operator.
Definition variable_matrix.hpp:753
VariableMatrix(const std::vector< std::vector< Variable< Scalar > > > &list)
Constructs a scalar VariableMatrix from a nested list of Variables.
Definition variable_matrix.hpp:126
VariableMatrix & operator/=(const ScalarLike auto &rhs)
Compound matrix division-assignment operator.
Definition variable_matrix.hpp:737
const Variable< Scalar > & operator[](int index) const
Returns the element at the given index.
Definition variable_matrix.hpp:336
int cols() const
Returns the number of columns in the matrix.
Definition variable_matrix.hpp:977
Definition function_ref.hpp:13
FMT_CONSTEXPR auto fg(detail::color_type foreground) noexcept -> text_style
Creates a text style from the foreground (text) color.
Definition color.h:348
FMT_CONSTEXPR auto bg(detail::color_type background) noexcept -> text_style
Creates a text style from the background color.
Definition color.h:354
Definition concepts.hpp:18
Definition concepts.hpp:24
Definition concepts.hpp:33
Definition concepts.hpp:38
Definition small_vector.hpp:7
wpi::util::SmallVector< T > small_vector
Definition small_vector.hpp:10
static constexpr empty_t empty
Designates an uninitialized VariableMatrix.
Definition empty.hpp:11
Definition to_underlying.hpp:7
VariableMatrix< Scalar > solve(const VariableMatrix< Scalar > &A, const VariableMatrix< Scalar > &B)
Solves the VariableMatrix equation AX = B for X.
Definition variable_matrix.hpp:1398
VariableMatrix< Scalar > cwise_reduce(const VariableMatrix< Scalar > &lhs, const VariableMatrix< Scalar > &rhs, function_ref< Variable< Scalar >(const Variable< Scalar > &x, const Variable< Scalar > &y)> binary_op)
Applies a coefficient-wise reduce operation to two matrices.
Definition variable_matrix.hpp:1261
VariableMatrix(const Eigen::MatrixBase< Derived > &) -> VariableMatrix< typename Derived::Scalar >
VariableMatrix< Scalar > block(std::initializer_list< std::initializer_list< VariableMatrix< Scalar > > > list)
Assembles a VariableMatrix from a nested list of blocks.
Definition variable_matrix.hpp:1289
Type tag used to designate an uninitialized VariableMatrix.
Definition empty.hpp:8
#define SLEIPNIR_DLLEXPORT
Definition symbol_exports.hpp:34