8#include <initializer_list>
16#include <gch/small_vector.hpp>
18#include "sleipnir/autodiff/expression_graph.hpp"
19#include "sleipnir/autodiff/sleipnir_base.hpp"
20#include "sleipnir/autodiff/slice.hpp"
21#include "sleipnir/autodiff/variable.hpp"
22#include "sleipnir/autodiff/variable_block.hpp"
23#include "sleipnir/util/assert.hpp"
24#include "sleipnir/util/concepts.hpp"
25#include "sleipnir/util/empty.hpp"
26#include "sleipnir/util/function_ref.hpp"
27#include "sleipnir/util/symbol_exports.hpp"
34template <
typename Scalar_>
55 for (
int index = 0; index <
rows *
cols; ++index) {
56 m_storage.emplace_back();
67 for (
int index = 0; index <
rows *
cols; ++index) {
68 m_storage.emplace_back(
nullptr);
80 if (list.size() > 0) {
81 m_cols = list.begin()->size();
86 const auto&
row : list) {
87 slp_assert(
static_cast<int>(
row.size()) == m_cols);
91 for (
const auto&
row : list) {
92 std::ranges::copy(
row, std::back_inserter(m_storage));
104 m_rows = list.size();
106 if (list.size() > 0) {
107 m_cols = list.begin()->size();
112 const auto&
row : list) {
113 slp_assert(
static_cast<int>(
row.size()) == m_cols);
117 for (
const auto&
row : list) {
118 std::ranges::copy(
row, std::back_inserter(m_storage));
130 m_rows = list.size();
132 if (list.size() > 0) {
133 m_cols = list.begin()->size();
138 const auto&
row : list) {
139 slp_assert(
static_cast<int>(
row.size()) == m_cols);
143 for (
const auto&
row : list) {
144 std::ranges::copy(
row, std::back_inserter(m_storage));
151 template <
typename Derived>
167 template <
typename Derived>
176 m_storage.emplace_back(
values.diagonal()[
row]);
178 m_storage.emplace_back(
Scalar(0));
197 m_storage.emplace_back(std::move(
variable));
261 template <
typename Derived>
281 slp_assert(
rows() == 1 &&
cols() == 1);
283 (*this)[0, 0] =
value;
291 template <
typename Derived>
292 requires std::same_as<typename Derived::Scalar, Scalar>
330 slp_assert(index >= 0 && index <
rows() *
cols());
331 return m_storage[index];
339 slp_assert(index >= 0 && index <
rows() *
cols());
340 return m_storage[index];
443 slp_assert(
cols() == 1);
456 slp_assert(
cols() == 1);
502 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
504 slp_assert(
lhs.cols() ==
rhs.rows());
508 for (
int i = 0;
i <
lhs.rows(); ++
i) {
509 for (
int j = 0;
j <
rhs.cols(); ++
j) {
511 for (
int k = 0;
k <
lhs.cols(); ++
k) {
525 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
527 slp_assert(
lhs.cols() ==
rhs.rows());
531 for (
int i = 0;
i <
lhs.rows(); ++
i) {
532 for (
int j = 0;
j <
rhs.cols(); ++
j) {
534 for (
int k = 0;
k <
lhs.cols(); ++
k) {
548 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
550 slp_assert(
lhs.cols() ==
rhs.rows());
554 for (
int i = 0;
i <
lhs.rows(); ++
i) {
555 for (
int j = 0;
j <
rhs.cols(); ++
j) {
557 for (
int k = 0;
k <
lhs.cols(); ++
k) {
571 template <EigenMatrixLike LHS>
589 template <SleipnirMatrixLike<Scalar> LHS, ScalarLike RHS>
606 template <EigenMatrixLike RHS>
624 template <ScalarLike LHS, SleipnirMatrixLike<Scalar> RHS>
644 for (
int i = 0;
i <
rows(); ++
i) {
646 for (
int j = 0;
j <
rhs.cols(); ++
j) {
648 for (
int k = 0;
k <
cols(); ++
k) {
677 template <EigenMatrixLike LHS>
696 template <SleipnirMatrixLike<Scalar> LHS, ScalarLike RHS>
715 template <SleipnirMatrixLike<Scalar> LHS>
748 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
750 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
768 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
770 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
788 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
790 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
824 slp_assert(
rows() == 1 &&
cols() == 1);
840 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
842 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
860 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
862 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
880 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
882 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
916 slp_assert(
rows() == 1 &&
cols() == 1);
946 slp_assert(
rows() == 1 &&
cols() == 1);
947 return (*
this)[0, 0];
968 int rows()
const {
return m_rows; }
973 int cols()
const {
return m_cols; }
991 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
value() {
992 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
result{
rows(),
1022#ifndef DOXYGEN_SHOULD_SKIP_THIS
1038 constexpr iterator& operator++() noexcept {
1043 constexpr iterator operator++(
int)
noexcept {
1044 iterator retval = *
this;
1049 constexpr iterator& operator--() noexcept {
1054 constexpr iterator operator--(
int)
noexcept {
1055 iterator retval = *
this;
1060 constexpr bool operator==(
const iterator&)
const noexcept =
default;
1062 constexpr reference operator*() const noexcept {
return *m_it; }
1065 gch::small_vector<Variable<Scalar>>::iterator m_it;
1068 class const_iterator {
1070 using iterator_category = std::bidirectional_iterator_tag;
1071 using value_type = Variable<Scalar>;
1072 using difference_type = std::ptrdiff_t;
1073 using pointer = Variable<Scalar>*;
1074 using const_reference =
const Variable<Scalar>&;
1076 constexpr const_iterator() noexcept = default;
1078 explicit constexpr const_iterator(
1079 gch::small_vector<Variable<Scalar>>::const_iterator it) noexcept
1082 constexpr const_iterator& operator++() noexcept {
1087 constexpr const_iterator operator++(
int)
noexcept {
1088 const_iterator retval = *
this;
1093 constexpr const_iterator& operator--() noexcept {
1098 constexpr const_iterator operator--(
int)
noexcept {
1099 const_iterator retval = *
this;
1104 constexpr bool operator==(
const const_iterator&)
const noexcept =
default;
1106 constexpr const_reference operator*() const noexcept {
return *m_it; }
1109 gch::small_vector<Variable<Scalar>>::const_iterator m_it;
1112 using reverse_iterator = std::reverse_iterator<iterator>;
1113 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
1120 iterator
begin() {
return iterator{m_storage.begin()}; }
1125 iterator
end() {
return iterator{m_storage.end()}; }
1130 const_iterator
begin()
const {
return const_iterator{m_storage.begin()}; }
1135 const_iterator
end()
const {
return const_iterator{m_storage.end()}; }
1140 const_iterator
cbegin()
const {
return const_iterator{m_storage.cbegin()}; }
1145 const_iterator
cend()
const {
return const_iterator{m_storage.cend()}; }
1150 reverse_iterator
rbegin() {
return reverse_iterator{
end()}; }
1155 reverse_iterator
rend() {
return reverse_iterator{
begin()}; }
1161 return const_reverse_iterator{
end()};
1167 const_reverse_iterator
rend()
const {
1168 return const_reverse_iterator{
begin()};
1175 return const_reverse_iterator{
cend()};
1182 return const_reverse_iterator{
cbegin()};
1188 size_t size()
const {
return m_storage.size(); }
1237 gch::small_vector<Variable<Scalar>> m_storage;
1242template <
typename Derived>
1243VariableMatrix(
const Eigen::MatrixBase<Derived>&)
1244 -> VariableMatrix<typename Derived::Scalar>;
1246template <
typename Derived>
1247VariableMatrix(
const Eigen::DiagonalBase<Derived>&)
1248 -> VariableMatrix<typename Derived::Scalar>;
1256template <
typename Scalar>
1257VariableMatrix<Scalar> cwise_reduce(
1258 const VariableMatrix<Scalar>& lhs,
const VariableMatrix<Scalar>& rhs,
1259 function_ref<Variable<Scalar>(
const Variable<Scalar>& x,
1260 const Variable<Scalar>& y)>
1262 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
1264 VariableMatrix<Scalar> result{detail::empty, lhs.rows(), lhs.cols()};
1266 for (
int row = 0; row < lhs.rows(); ++row) {
1267 for (
int col = 0; col < lhs.cols(); ++col) {
1268 result[row, col] = binary_op(lhs[row, col], rhs[row, col]);
1284template <
typename Scalar>
1285VariableMatrix<Scalar> block(
1286 std::initializer_list<std::initializer_list<VariableMatrix<Scalar>>> list) {
1290 for (
const auto& row : list) {
1291 if (row.size() > 0) {
1292 rows += row.
begin()->rows();
1296 int latest_cols = 0;
1297 for (
const auto& elem : row) {
1299 slp_assert(row.begin()->rows() == elem.rows());
1301 latest_cols += elem.cols();
1309 slp_assert(cols == latest_cols);
1313 VariableMatrix<Scalar> result{detail::empty, rows, cols};
1316 for (
const auto& row : list) {
1318 for (
const auto& elem : row) {
1319 result.block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1320 col_offset += elem.cols();
1322 if (row.size() > 0) {
1323 row_offset += row.begin()->rows();
1341template <
typename Scalar>
1342VariableMatrix<Scalar> block(
1343 const std::vector<std::vector<VariableMatrix<Scalar>>>& list) {
1347 for (
const auto& row : list) {
1348 if (row.size() > 0) {
1349 rows += row.
begin()->rows();
1353 int latest_cols = 0;
1354 for (
const auto& elem : row) {
1356 slp_assert(row.begin()->rows() == elem.rows());
1358 latest_cols += elem.cols();
1366 slp_assert(cols == latest_cols);
1370 VariableMatrix<Scalar> result{detail::empty, rows, cols};
1373 for (
const auto& row : list) {
1375 for (
const auto& elem : row) {
1376 result.block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1377 col_offset += elem.cols();
1379 if (row.size() > 0) {
1380 row_offset += row.begin()->rows();
1393template <
typename Scalar>
1394VariableMatrix<Scalar> solve(
const VariableMatrix<Scalar>& A,
1395 const VariableMatrix<Scalar>& B) {
1397 slp_assert(A.rows() == B.rows());
1399 if (A.rows() == 1 && A.cols() == 1) {
1401 return B[0, 0] / A[0, 0];
1402 }
else if (A.rows() == 2 && A.cols() == 2) {
1408 const auto& a = A[0, 0];
1409 const auto& b = A[0, 1];
1410 const auto& c = A[1, 0];
1411 const auto& d = A[1, 1];
1413 VariableMatrix adj_A{{d, -b}, {-c, a}};
1414 auto det_A = a * d - b * c;
1415 return adj_A / det_A * B;
1416 }
else if (A.rows() == 3 && A.cols() == 3) {
1428 const auto& a = A[0, 0];
1429 const auto& b = A[0, 1];
1430 const auto& c = A[0, 2];
1431 const auto& d = A[1, 0];
1432 const auto& e = A[1, 1];
1433 const auto& f = A[1, 2];
1434 const auto& g = A[2, 0];
1435 const auto& h = A[2, 1];
1436 const auto& i = A[2, 2];
1457 auto adj_A00 = ei - fh;
1458 auto adj_A10 = fg - di;
1459 auto adj_A20 = dh - eg;
1461 VariableMatrix adj_A{{adj_A00, ch - bi, bf - ce},
1462 {adj_A10, ai - cg, cd - af},
1463 {adj_A20, bg - ah, ae - bd}};
1464 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20;
1465 return adj_A / det_A * B;
1466 }
else if (A.rows() == 4 && A.cols() == 4) {
1476 const auto& a = A[0, 0];
1477 const auto& b = A[0, 1];
1478 const auto& c = A[0, 2];
1479 const auto& d = A[0, 3];
1480 const auto& e = A[1, 0];
1481 const auto& f = A[1, 1];
1482 const auto& g = A[1, 2];
1483 const auto& h = A[1, 3];
1484 const auto& i = A[2, 0];
1485 const auto& j = A[2, 1];
1486 const auto& k = A[2, 2];
1487 const auto& l = A[2, 3];
1488 const auto& m = A[3, 0];
1489 const auto& n = A[3, 1];
1490 const auto& o = A[3, 2];
1491 const auto& p = A[3, 3];
1493 auto afk = a * f * k;
1494 auto afl = a * f * l;
1495 auto afo = a * f * o;
1496 auto afp = a * f * p;
1497 auto agj = a * g * j;
1498 auto agl = a * g * l;
1499 auto agn = a * g * n;
1500 auto agp = a * g * p;
1501 auto ahj = a * h * j;
1502 auto ahk = a * h * k;
1503 auto ahn = a * h * n;
1504 auto aho = a * h * o;
1505 auto ajo = a * j * o;
1506 auto ajp = a * j * p;
1507 auto akn = a * k * n;
1508 auto akp = a * k * p;
1509 auto aln = a * l * n;
1510 auto alo = a * l * o;
1511 auto bek = b * e * k;
1512 auto bel = b * e * l;
1513 auto beo = b * e * o;
1514 auto bep = b * e * p;
1515 auto bgi = b * g * i;
1516 auto bgl = b * g * l;
1517 auto bgm = b * g * m;
1518 auto bgp = b * g * p;
1519 auto bhi = b * h * i;
1520 auto bhk = b * h * k;
1521 auto bhm = b * h * m;
1522 auto bho = b * h * o;
1523 auto bio = b * i * o;
1524 auto bip = b * i * p;
1525 auto bjp = b * j * p;
1526 auto bkm = b * k * m;
1527 auto bkp = b * k * p;
1528 auto blm = b * l * m;
1529 auto blo = b * l * o;
1530 auto cej = c * e * j;
1531 auto cel = c * e * l;
1532 auto cen = c * e * n;
1533 auto cep = c * e * p;
1534 auto cfi = c * f * i;
1535 auto cfl = c * f * l;
1536 auto cfm = c * f * m;
1537 auto cfp = c * f * p;
1538 auto chi = c * h * i;
1539 auto chj = c * h * j;
1540 auto chm = c * h * m;
1541 auto chn = c * h * n;
1542 auto cin = c * i * n;
1543 auto cip = c * i * p;
1544 auto cjm = c * j * m;
1545 auto cjp = c * j * p;
1546 auto clm = c * l * m;
1547 auto cln = c * l * n;
1548 auto dej = d * e * j;
1549 auto dek = d * e * k;
1550 auto den = d * e * n;
1551 auto deo = d * e * o;
1552 auto dfi = d * f * i;
1553 auto dfk = d * f * k;
1554 auto dfm = d * f * m;
1555 auto dfo = d * f * o;
1556 auto dgi = d * g * i;
1557 auto dgj = d * g * j;
1558 auto dgm = d * g * m;
1559 auto dgn = d * g * n;
1560 auto din = d * i * n;
1561 auto dio = d * i * o;
1562 auto djm = d * j * m;
1563 auto djo = d * j * o;
1564 auto dkm = d * k * m;
1565 auto dkn = d * k * n;
1566 auto ejo = e * j * o;
1567 auto ejp = e * j * p;
1568 auto ekn = e * k * n;
1569 auto ekp = e * k * p;
1570 auto eln = e * l * n;
1571 auto elo = e * l * o;
1572 auto fio = f * i * o;
1573 auto fip = f * i * p;
1574 auto fkm = f * k * m;
1575 auto fkp = f * k * p;
1576 auto flm = f * l * m;
1577 auto flo = f * l * o;
1578 auto gin = g * i * n;
1579 auto gip = g * i * p;
1580 auto gjm = g * j * m;
1581 auto gjp = g * j * p;
1582 auto glm = g * l * m;
1583 auto gln = g * l * n;
1584 auto hin = h * i * n;
1585 auto hio = h * i * o;
1586 auto hjm = h * j * m;
1587 auto hjo = h * j * o;
1588 auto hkm = h * k * m;
1589 auto hkn = h * k * n;
1591 auto adj_A00 = fkp - flo - gjp + gln + hjo - hkn;
1592 auto adj_A01 = -bkp + blo + cjp - cln - djo + dkn;
1593 auto adj_A02 = bgp - bho - cfp + chn + dfo - dgn;
1594 auto adj_A03 = -bgl + bhk + cfl - chj - dfk + dgj;
1595 auto adj_A10 = -ekp + elo + gip - glm - hio + hkm;
1596 auto adj_A11 = akp - alo - cip + clm + dio - dkm;
1597 auto adj_A12 = -agp + aho + cep - chm - deo + dgm;
1598 auto adj_A13 = agl - ahk - cel + chi + dek - dgi;
1599 auto adj_A20 = ejp - eln - fip + flm + hin - hjm;
1600 auto adj_A21 = -ajp + aln + bip - blm - din + djm;
1601 auto adj_A22 = afp - ahn - bep + bhm + den - dfm;
1602 auto adj_A23 = -afl + ahj + bel - bhi - dej + dfi;
1603 auto adj_A30 = -ejo + ekn + fio - fkm - gin + gjm;
1605 auto adj_A31 = ajo - akn - bio + bkm + cin - cjm;
1606 auto adj_A32 = -afo + agn + beo - bgm - cen + cfm;
1607 auto adj_A33 = afk - agj - bek + bgi + cej - cfi;
1609 VariableMatrix adj_A{{adj_A00, adj_A01, adj_A02, adj_A03},
1610 {adj_A10, adj_A11, adj_A12, adj_A13},
1611 {adj_A20, adj_A21, adj_A22, adj_A23},
1612 {adj_A30, adj_A31, adj_A32, adj_A33}};
1613 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20 + d * adj_A30;
1614 return adj_A / det_A * B;
1617 Eigen::Matrix<Variable<Scalar>, Eigen::Dynamic, Eigen::Dynamic>;
1619 MatrixXv eigen_A{A.rows(), A.cols()};
1620 for (
int row = 0; row < A.rows(); ++row) {
1621 for (
int col = 0; col < A.cols(); ++col) {
1622 eigen_A[row, col] = A[row, col];
1626 MatrixXv eigen_B{B.rows(), B.cols()};
1627 for (
int row = 0; row < B.rows(); ++row) {
1628 for (
int col = 0; col < B.cols(); ++col) {
1629 eigen_B[row, col] = B[row, col];
1633 MatrixXv eigen_X = eigen_A.householderQr().solve(eigen_B);
1635 VariableMatrix<Scalar> X{detail::empty, A.cols(), B.cols()};
1636 for (
int row = 0; row < X.rows(); ++row) {
1637 for (
int col = 0; col < X.cols(); ++col) {
1638 X[row, col] = eigen_X[row, col];
1659template <
typename Scalar>
1660VariableMatrix<Scalar> gradient_tree(
const ExpressionGraph<Scalar>& top_list,
1661 const VariableMatrix<Scalar>& wrt) {
1662 slp_assert(wrt.cols() == 1);
1667 if (top_list.empty()) {
1668 return VariableMatrix<Scalar>{detail::empty, wrt.rows(), 1};
1672 top_list[0]->adjoint_expr = constant_ptr(Scalar(1));
1678 for (
auto& node : top_list) {
1679 auto& lhs = node->args[0];
1680 auto& rhs = node->args[1];
1682 if (lhs !=
nullptr) {
1683 if (rhs !=
nullptr) {
1685 lhs->adjoint_expr += node->grad_expr_l(lhs, rhs);
1686 rhs->adjoint_expr += node->grad_expr_r(lhs, rhs);
1689 lhs->adjoint_expr += node->grad_expr_l(lhs, rhs);
1695 VariableMatrix<Scalar> grad{detail::empty, wrt.rows(), 1};
1696 for (
int row = 0; row < grad.rows(); ++row) {
1697 grad[row] = Variable{std::move(wrt[row].expr->adjoint_expr)};
1703 for (
auto& node : top_list) {
1704 node->adjoint_expr =
nullptr;
1712extern template SLEIPNIR_DLLEXPORT VariableMatrix<double> solve(
1713 const VariableMatrix<double>& A,
const VariableMatrix<double>& B);
Definition intrusive_shared_ptr.hpp:27
Definition sleipnir_base.hpp:9
Represents a sequence of elements in an iterable object.
Definition slice.hpp:25
Definition variable_block.hpp:27
Definition variable_matrix.hpp:35
const_reverse_iterator crbegin() const
Definition variable_matrix.hpp:1174
VariableMatrix(std::initializer_list< std::initializer_list< Variable< Scalar > > > list)
Definition variable_matrix.hpp:75
const_reverse_iterator crend() const
Definition variable_matrix.hpp:1181
Scalar_ Scalar
Scalar type alias.
Definition variable_matrix.hpp:38
iterator end()
Definition variable_matrix.hpp:1125
const Variable< Scalar > & operator[](int row, int col) const
Definition variable_matrix.hpp:319
VariableMatrix(Variable< Scalar > &&variable)
Definition variable_matrix.hpp:196
const VariableBlock< const VariableMatrix > block(int row_offset, int col_offset, int block_rows, int block_cols) const
Definition variable_matrix.hpp:366
size_t size() const
Definition variable_matrix.hpp:1188
static VariableMatrix< Scalar > zero(int rows, int cols)
Definition variable_matrix.hpp:1195
VariableBlock< VariableMatrix > block(int row_offset, int col_offset, int block_rows, int block_cols)
Definition variable_matrix.hpp:350
VariableMatrix(const std::vector< std::vector< Scalar > > &list)
Definition variable_matrix.hpp:102
VariableMatrix & operator=(ScalarLike auto value)
Definition variable_matrix.hpp:280
VariableMatrix & operator-=(const MatrixLike auto &rhs)
Definition variable_matrix.hpp:899
Variable< Scalar > & operator[](int index)
Definition variable_matrix.hpp:329
VariableMatrix & operator=(const Eigen::MatrixBase< Derived > &values)
Definition variable_matrix.hpp:262
friend VariableMatrix< Scalar > operator-(const LHS &lhs, const RHS &rhs)
Definition variable_matrix.hpp:841
VariableMatrix & operator-=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:915
friend VariableMatrix< Scalar > operator*(const Variable< Scalar > &lhs, const RHS &rhs)
Definition variable_matrix.hpp:607
VariableMatrix & operator*=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:662
Scalar value(int index)
Definition variable_matrix.hpp:986
VariableMatrix(const VariableBlock< VariableMatrix > &values)
Definition variable_matrix.hpp:204
VariableMatrix(int rows, int cols)
Definition variable_matrix.hpp:53
const_iterator cbegin() const
Definition variable_matrix.hpp:1140
const_iterator begin() const
Definition variable_matrix.hpp:1130
const_iterator cend() const
Definition variable_matrix.hpp:1145
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > value()
Definition variable_matrix.hpp:991
const VariableBlock< const VariableMatrix > operator[](Slice row_slice, Slice col_slice) const
Definition variable_matrix.hpp:394
friend VariableMatrix< Scalar > operator/(const LHS &lhs, const Variable< Scalar > &rhs)
Definition variable_matrix.hpp:678
VariableMatrix(int rows)
Definition variable_matrix.hpp:47
VariableMatrix(std::span< const Variable< Scalar > > values, int rows, int cols)
Definition variable_matrix.hpp:246
VariableBlock< VariableMatrix > col(int col)
Definition variable_matrix.hpp:484
VariableMatrix(const Eigen::MatrixBase< Derived > &values)
Definition variable_matrix.hpp:153
const VariableBlock< const VariableMatrix > operator[](Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length) const
Definition variable_matrix.hpp:430
const VariableBlock< const VariableMatrix > col(int col) const
Definition variable_matrix.hpp:493
VariableMatrix & operator+=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:823
friend VariableMatrix< Scalar > operator*(const LHS &lhs, const Variable< Scalar > &rhs)
Definition variable_matrix.hpp:572
VariableBlock< VariableMatrix > segment(int offset, int length)
Definition variable_matrix.hpp:442
Scalar value(int row, int col)
Definition variable_matrix.hpp:980
const VariableBlock< const VariableMatrix > row(int row) const
Definition variable_matrix.hpp:475
VariableMatrix()=default
Constructs an empty VariableMatrix.
VariableMatrix & operator+=(const MatrixLike auto &rhs)
Definition variable_matrix.hpp:807
VariableMatrix(std::span< const Variable< Scalar > > values)
Definition variable_matrix.hpp:231
friend VariableMatrix< Scalar > operator-(const SleipnirMatrixLike< Scalar > auto &lhs)
Definition variable_matrix.hpp:930
static VariableMatrix< Scalar > constant(int rows, int cols, Scalar constant)
Definition variable_matrix.hpp:1226
VariableMatrix< Scalar > T() const
Definition variable_matrix.hpp:953
VariableMatrix< Scalar > cwise_transform(function_ref< Variable< Scalar >(const Variable< Scalar > &x)> unary_op) const
Definition variable_matrix.hpp:1008
friend VariableMatrix< Scalar > operator*(const LHS &lhs, const RHS &rhs)
Definition variable_matrix.hpp:503
const_reverse_iterator rbegin() const
Definition variable_matrix.hpp:1160
VariableMatrix(const Variable< Scalar > &variable)
Definition variable_matrix.hpp:188
reverse_iterator rend()
Definition variable_matrix.hpp:1155
VariableMatrix(const VariableBlock< const VariableMatrix > &values)
Definition variable_matrix.hpp:218
int rows() const
Definition variable_matrix.hpp:968
static VariableMatrix< Scalar > one(int rows, int cols)
Definition variable_matrix.hpp:1210
VariableMatrix(const Eigen::DiagonalBase< Derived > &values)
Definition variable_matrix.hpp:169
VariableBlock< VariableMatrix > operator[](Slice row_slice, Slice col_slice)
Definition variable_matrix.hpp:382
const_reverse_iterator rend() const
Definition variable_matrix.hpp:1167
VariableMatrix & operator*=(const MatrixLike auto &rhs)
Definition variable_matrix.hpp:641
VariableMatrix(detail::empty_t, int rows, int cols)
Definition variable_matrix.hpp:64
const_iterator end() const
Definition variable_matrix.hpp:1135
void set_value(const Eigen::MatrixBase< Derived > &values)
Definition variable_matrix.hpp:293
Variable< Scalar > & operator[](int row, int col)
Definition variable_matrix.hpp:308
iterator begin()
Definition variable_matrix.hpp:1120
const VariableBlock< const VariableMatrix > segment(int offset, int length) const
Definition variable_matrix.hpp:454
reverse_iterator rbegin()
Definition variable_matrix.hpp:1150
VariableBlock< VariableMatrix > row(int row)
Definition variable_matrix.hpp:466
friend VariableMatrix< Scalar > operator+(const LHS &lhs, const RHS &rhs)
Definition variable_matrix.hpp:749
VariableMatrix(const std::vector< std::vector< Variable< Scalar > > > &list)
Definition variable_matrix.hpp:128
VariableBlock< VariableMatrix > operator[](Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length)
Definition variable_matrix.hpp:412
VariableMatrix & operator/=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:733
const Variable< Scalar > & operator[](int index) const
Definition variable_matrix.hpp:338
int cols() const
Definition variable_matrix.hpp:973
Definition variable.hpp:55
Definition function_ref.hpp:13
Definition concepts.hpp:18
Definition concepts.hpp:24
Definition concepts.hpp:33
Definition concepts.hpp:38
Type tag used to designate an uninitialized VariableMatrix.
Definition empty.hpp:8