7#include <initializer_list>
15#include <gch/small_vector.hpp>
17#include "sleipnir/autodiff/sleipnir_base.hpp"
18#include "sleipnir/autodiff/slice.hpp"
19#include "sleipnir/autodiff/variable.hpp"
20#include "sleipnir/autodiff/variable_block.hpp"
21#include "sleipnir/util/assert.hpp"
22#include "sleipnir/util/concepts.hpp"
23#include "sleipnir/util/empty.hpp"
24#include "sleipnir/util/function_ref.hpp"
25#include "sleipnir/util/symbol_exports.hpp"
32template <
typename Scalar_>
53 for (
int index = 0; index <
rows *
cols; ++index) {
54 m_storage.emplace_back();
65 for (
int index = 0; index <
rows *
cols; ++index) {
66 m_storage.emplace_back(
nullptr);
78 if (list.size() > 0) {
79 m_cols = list.begin()->size();
84 const auto&
row : list) {
85 slp_assert(
static_cast<int>(
row.size()) == m_cols);
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();
110 const auto&
row : list) {
111 slp_assert(
static_cast<int>(
row.size()) == m_cols);
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();
136 const auto&
row : list) {
137 slp_assert(
static_cast<int>(
row.size()) == m_cols);
141 for (
const auto&
row : list) {
142 std::ranges::copy(
row, std::back_inserter(m_storage));
149 template <
typename Derived>
165 template <
typename Derived>
174 m_storage.emplace_back(
values.diagonal()[
row]);
176 m_storage.emplace_back(
Scalar(0));
195 m_storage.emplace_back(std::move(
variable));
259 template <
typename Derived>
279 slp_assert(
rows() == 1 &&
cols() == 1);
281 (*this)[0, 0] =
value;
289 template <
typename Derived>
290 requires std::same_as<typename Derived::Scalar, Scalar>
328 slp_assert(index >= 0 && index <
rows() *
cols());
329 return m_storage[index];
337 slp_assert(index >= 0 && index <
rows() *
cols());
338 return m_storage[index];
441 slp_assert(
cols() == 1);
454 slp_assert(
cols() == 1);
500 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
502 slp_assert(
lhs.cols() ==
rhs.rows());
506 for (
int i = 0;
i <
lhs.rows(); ++
i) {
507 for (
int j = 0;
j <
rhs.cols(); ++
j) {
509 for (
int k = 0;
k <
lhs.cols(); ++
k) {
523 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
525 slp_assert(
lhs.cols() ==
rhs.rows());
529 for (
int i = 0;
i <
lhs.rows(); ++
i) {
530 for (
int j = 0;
j <
rhs.cols(); ++
j) {
532 for (
int k = 0;
k <
lhs.cols(); ++
k) {
546 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
548 slp_assert(
lhs.cols() ==
rhs.rows());
552 for (
int i = 0;
i <
lhs.rows(); ++
i) {
553 for (
int j = 0;
j <
rhs.cols(); ++
j) {
555 for (
int k = 0;
k <
lhs.cols(); ++
k) {
569 template <EigenMatrixLike LHS>
587 template <SleipnirMatrixLike<Scalar> LHS, ScalarLike RHS>
604 template <EigenMatrixLike RHS>
622 template <ScalarLike LHS, SleipnirMatrixLike<Scalar> RHS>
642 for (
int i = 0;
i <
rows(); ++
i) {
643 for (
int j = 0;
j <
rhs.cols(); ++
j) {
645 for (
int k = 0;
k <
cols(); ++
k) {
674 template <EigenMatrixLike LHS>
693 template <SleipnirMatrixLike<Scalar> LHS, ScalarLike RHS>
712 template <SleipnirMatrixLike<Scalar> LHS>
745 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
747 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
765 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
767 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
785 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
787 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
821 slp_assert(
rows() == 1 &&
cols() == 1);
837 template <EigenMatrixLike LHS, SleipnirMatrixLike<Scalar> RHS>
839 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
857 template <SleipnirMatrixLike<Scalar> LHS, EigenMatrixLike RHS>
859 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
877 template <SleipnirMatrixLike<Scalar> LHS, SleipnirMatrixLike<Scalar> RHS>
879 slp_assert(
lhs.rows() ==
rhs.rows() &&
lhs.cols() ==
rhs.cols());
913 slp_assert(
rows() == 1 &&
cols() == 1);
943 slp_assert(
rows() == 1 &&
cols() == 1);
944 return (*
this)[0, 0];
965 int rows()
const {
return m_rows; }
970 int cols()
const {
return m_cols; }
988 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
value() {
989 Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>
result{
rows(),
1019#ifndef DOXYGEN_SHOULD_SKIP_THIS
1035 constexpr iterator& operator++() noexcept {
1040 constexpr iterator operator++(
int)
noexcept {
1041 iterator retval = *
this;
1046 constexpr iterator& operator--() noexcept {
1051 constexpr iterator operator--(
int)
noexcept {
1052 iterator retval = *
this;
1057 constexpr bool operator==(
const iterator&)
const noexcept =
default;
1059 constexpr reference operator*() const noexcept {
return *m_it; }
1062 gch::small_vector<Variable<Scalar>>::iterator m_it;
1065 class const_iterator {
1067 using iterator_category = std::bidirectional_iterator_tag;
1068 using value_type = Variable<Scalar>;
1069 using difference_type = std::ptrdiff_t;
1070 using pointer = Variable<Scalar>*;
1071 using const_reference =
const Variable<Scalar>&;
1073 constexpr const_iterator() noexcept = default;
1075 explicit constexpr const_iterator(
1076 gch::small_vector<Variable<Scalar>>::const_iterator it) noexcept
1079 constexpr const_iterator& operator++() noexcept {
1084 constexpr const_iterator operator++(
int)
noexcept {
1085 const_iterator retval = *
this;
1090 constexpr const_iterator& operator--() noexcept {
1095 constexpr const_iterator operator--(
int)
noexcept {
1096 const_iterator retval = *
this;
1101 constexpr bool operator==(
const const_iterator&)
const noexcept =
default;
1103 constexpr const_reference operator*() const noexcept {
return *m_it; }
1106 gch::small_vector<Variable<Scalar>>::const_iterator m_it;
1109 using reverse_iterator = std::reverse_iterator<iterator>;
1110 using const_reverse_iterator = std::reverse_iterator<const_iterator>;
1117 iterator
begin() {
return iterator{m_storage.begin()}; }
1122 iterator
end() {
return iterator{m_storage.end()}; }
1127 const_iterator
begin()
const {
return const_iterator{m_storage.begin()}; }
1132 const_iterator
end()
const {
return const_iterator{m_storage.end()}; }
1137 const_iterator
cbegin()
const {
return const_iterator{m_storage.cbegin()}; }
1142 const_iterator
cend()
const {
return const_iterator{m_storage.cend()}; }
1147 reverse_iterator
rbegin() {
return reverse_iterator{
end()}; }
1152 reverse_iterator
rend() {
return reverse_iterator{
begin()}; }
1158 return const_reverse_iterator{
end()};
1164 const_reverse_iterator
rend()
const {
1165 return const_reverse_iterator{
begin()};
1172 return const_reverse_iterator{
cend()};
1179 return const_reverse_iterator{
cbegin()};
1185 size_t size()
const {
return m_storage.size(); }
1234 gch::small_vector<Variable<Scalar>> m_storage;
1239template <
typename Derived>
1240VariableMatrix(
const Eigen::MatrixBase<Derived>&)
1241 -> VariableMatrix<typename Derived::Scalar>;
1243template <
typename Derived>
1244VariableMatrix(
const Eigen::DiagonalBase<Derived>&)
1245 -> VariableMatrix<typename Derived::Scalar>;
1253template <
typename Scalar>
1254VariableMatrix<Scalar> cwise_reduce(
1255 const VariableMatrix<Scalar>& lhs,
const VariableMatrix<Scalar>& rhs,
1256 function_ref<Variable<Scalar>(
const Variable<Scalar>& x,
1257 const Variable<Scalar>& y)>
1259 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
1261 VariableMatrix<Scalar> result{detail::empty, lhs.rows(), lhs.cols()};
1263 for (
int row = 0; row < lhs.rows(); ++row) {
1264 for (
int col = 0; col < lhs.cols(); ++col) {
1265 result[row, col] = binary_op(lhs[row, col], rhs[row, col]);
1281template <
typename Scalar>
1282VariableMatrix<Scalar> block(
1283 std::initializer_list<std::initializer_list<VariableMatrix<Scalar>>> list) {
1287 for (
const auto& row : list) {
1288 if (row.size() > 0) {
1289 rows += row.
begin()->rows();
1293 int latest_cols = 0;
1294 for (
const auto& elem : row) {
1296 slp_assert(row.begin()->rows() == elem.rows());
1298 latest_cols += elem.cols();
1306 slp_assert(cols == latest_cols);
1310 VariableMatrix<Scalar> result{detail::empty, rows, cols};
1313 for (
const auto& row : list) {
1315 for (
const auto& elem : row) {
1316 result.block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1317 col_offset += elem.cols();
1319 if (row.size() > 0) {
1320 row_offset += row.begin()->rows();
1338template <
typename Scalar>
1339VariableMatrix<Scalar> block(
1340 const std::vector<std::vector<VariableMatrix<Scalar>>>& list) {
1344 for (
const auto& row : list) {
1345 if (row.size() > 0) {
1346 rows += row.
begin()->rows();
1350 int latest_cols = 0;
1351 for (
const auto& elem : row) {
1353 slp_assert(row.begin()->rows() == elem.rows());
1355 latest_cols += elem.cols();
1363 slp_assert(cols == latest_cols);
1367 VariableMatrix<Scalar> result{detail::empty, rows, cols};
1370 for (
const auto& row : list) {
1372 for (
const auto& elem : row) {
1373 result.block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1374 col_offset += elem.cols();
1376 if (row.size() > 0) {
1377 row_offset += row.begin()->rows();
1390template <
typename Scalar>
1391VariableMatrix<Scalar> solve(
const VariableMatrix<Scalar>& A,
1392 const VariableMatrix<Scalar>& B) {
1394 slp_assert(A.rows() == B.rows());
1396 if (A.rows() == 1 && A.cols() == 1) {
1398 return B[0, 0] / A[0, 0];
1399 }
else if (A.rows() == 2 && A.cols() == 2) {
1405 const auto& a = A[0, 0];
1406 const auto& b = A[0, 1];
1407 const auto& c = A[1, 0];
1408 const auto& d = A[1, 1];
1410 VariableMatrix adj_A{{d, -b}, {-c, a}};
1411 auto det_A = a * d - b * c;
1412 return adj_A / det_A * B;
1413 }
else if (A.rows() == 3 && A.cols() == 3) {
1425 const auto& a = A[0, 0];
1426 const auto& b = A[0, 1];
1427 const auto& c = A[0, 2];
1428 const auto& d = A[1, 0];
1429 const auto& e = A[1, 1];
1430 const auto& f = A[1, 2];
1431 const auto& g = A[2, 0];
1432 const auto& h = A[2, 1];
1433 const auto& i = A[2, 2];
1454 auto adj_A00 = ei - fh;
1455 auto adj_A10 = fg - di;
1456 auto adj_A20 = dh - eg;
1458 VariableMatrix adj_A{{adj_A00, ch - bi, bf - ce},
1459 {adj_A10, ai - cg, cd - af},
1460 {adj_A20, bg - ah, ae - bd}};
1461 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20;
1462 return adj_A / det_A * B;
1463 }
else if (A.rows() == 4 && A.cols() == 4) {
1473 const auto& a = A[0, 0];
1474 const auto& b = A[0, 1];
1475 const auto& c = A[0, 2];
1476 const auto& d = A[0, 3];
1477 const auto& e = A[1, 0];
1478 const auto& f = A[1, 1];
1479 const auto& g = A[1, 2];
1480 const auto& h = A[1, 3];
1481 const auto& i = A[2, 0];
1482 const auto& j = A[2, 1];
1483 const auto& k = A[2, 2];
1484 const auto& l = A[2, 3];
1485 const auto& m = A[3, 0];
1486 const auto& n = A[3, 1];
1487 const auto& o = A[3, 2];
1488 const auto& p = A[3, 3];
1490 auto afk = a * f * k;
1491 auto afl = a * f * l;
1492 auto afo = a * f * o;
1493 auto afp = a * f * p;
1494 auto agj = a * g * j;
1495 auto agl = a * g * l;
1496 auto agn = a * g * n;
1497 auto agp = a * g * p;
1498 auto ahj = a * h * j;
1499 auto ahk = a * h * k;
1500 auto ahn = a * h * n;
1501 auto aho = a * h * o;
1502 auto ajo = a * j * o;
1503 auto ajp = a * j * p;
1504 auto akn = a * k * n;
1505 auto akp = a * k * p;
1506 auto aln = a * l * n;
1507 auto alo = a * l * o;
1508 auto bek = b * e * k;
1509 auto bel = b * e * l;
1510 auto beo = b * e * o;
1511 auto bep = b * e * p;
1512 auto bgi = b * g * i;
1513 auto bgl = b * g * l;
1514 auto bgm = b * g * m;
1515 auto bgp = b * g * p;
1516 auto bhi = b * h * i;
1517 auto bhk = b * h * k;
1518 auto bhm = b * h * m;
1519 auto bho = b * h * o;
1520 auto bio = b * i * o;
1521 auto bip = b * i * p;
1522 auto bjp = b * j * p;
1523 auto bkm = b * k * m;
1524 auto bkp = b * k * p;
1525 auto blm = b * l * m;
1526 auto blo = b * l * o;
1527 auto cej = c * e * j;
1528 auto cel = c * e * l;
1529 auto cen = c * e * n;
1530 auto cep = c * e * p;
1531 auto cfi = c * f * i;
1532 auto cfl = c * f * l;
1533 auto cfm = c * f * m;
1534 auto cfp = c * f * p;
1535 auto chi = c * h * i;
1536 auto chj = c * h * j;
1537 auto chm = c * h * m;
1538 auto chn = c * h * n;
1539 auto cin = c * i * n;
1540 auto cip = c * i * p;
1541 auto cjm = c * j * m;
1542 auto cjp = c * j * p;
1543 auto clm = c * l * m;
1544 auto cln = c * l * n;
1545 auto dej = d * e * j;
1546 auto dek = d * e * k;
1547 auto den = d * e * n;
1548 auto deo = d * e * o;
1549 auto dfi = d * f * i;
1550 auto dfk = d * f * k;
1551 auto dfm = d * f * m;
1552 auto dfo = d * f * o;
1553 auto dgi = d * g * i;
1554 auto dgj = d * g * j;
1555 auto dgm = d * g * m;
1556 auto dgn = d * g * n;
1557 auto din = d * i * n;
1558 auto dio = d * i * o;
1559 auto djm = d * j * m;
1560 auto djo = d * j * o;
1561 auto dkm = d * k * m;
1562 auto dkn = d * k * n;
1563 auto ejo = e * j * o;
1564 auto ejp = e * j * p;
1565 auto ekn = e * k * n;
1566 auto ekp = e * k * p;
1567 auto eln = e * l * n;
1568 auto elo = e * l * o;
1569 auto fio = f * i * o;
1570 auto fip = f * i * p;
1571 auto fkm = f * k * m;
1572 auto fkp = f * k * p;
1573 auto flm = f * l * m;
1574 auto flo = f * l * o;
1575 auto gin = g * i * n;
1576 auto gip = g * i * p;
1577 auto gjm = g * j * m;
1578 auto gjp = g * j * p;
1579 auto glm = g * l * m;
1580 auto gln = g * l * n;
1581 auto hin = h * i * n;
1582 auto hio = h * i * o;
1583 auto hjm = h * j * m;
1584 auto hjo = h * j * o;
1585 auto hkm = h * k * m;
1586 auto hkn = h * k * n;
1588 auto adj_A00 = fkp - flo - gjp + gln + hjo - hkn;
1589 auto adj_A01 = -bkp + blo + cjp - cln - djo + dkn;
1590 auto adj_A02 = bgp - bho - cfp + chn + dfo - dgn;
1591 auto adj_A03 = -bgl + bhk + cfl - chj - dfk + dgj;
1592 auto adj_A10 = -ekp + elo + gip - glm - hio + hkm;
1593 auto adj_A11 = akp - alo - cip + clm + dio - dkm;
1594 auto adj_A12 = -agp + aho + cep - chm - deo + dgm;
1595 auto adj_A13 = agl - ahk - cel + chi + dek - dgi;
1596 auto adj_A20 = ejp - eln - fip + flm + hin - hjm;
1597 auto adj_A21 = -ajp + aln + bip - blm - din + djm;
1598 auto adj_A22 = afp - ahn - bep + bhm + den - dfm;
1599 auto adj_A23 = -afl + ahj + bel - bhi - dej + dfi;
1600 auto adj_A30 = -ejo + ekn + fio - fkm - gin + gjm;
1602 auto adj_A31 = ajo - akn - bio + bkm + cin - cjm;
1603 auto adj_A32 = -afo + agn + beo - bgm - cen + cfm;
1604 auto adj_A33 = afk - agj - bek + bgi + cej - cfi;
1606 VariableMatrix adj_A{{adj_A00, adj_A01, adj_A02, adj_A03},
1607 {adj_A10, adj_A11, adj_A12, adj_A13},
1608 {adj_A20, adj_A21, adj_A22, adj_A23},
1609 {adj_A30, adj_A31, adj_A32, adj_A33}};
1610 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20 + d * adj_A30;
1611 return adj_A / det_A * B;
1614 Eigen::Matrix<Variable<Scalar>, Eigen::Dynamic, Eigen::Dynamic>;
1616 MatrixXv eigen_A{A.rows(), A.cols()};
1617 for (
int row = 0; row < A.rows(); ++row) {
1618 for (
int col = 0; col < A.cols(); ++col) {
1619 eigen_A[row, col] = A[row, col];
1623 MatrixXv eigen_B{B.rows(), B.cols()};
1624 for (
int row = 0; row < B.rows(); ++row) {
1625 for (
int col = 0; col < B.cols(); ++col) {
1626 eigen_B[row, col] = B[row, col];
1630 MatrixXv eigen_X = eigen_A.householderQr().solve(eigen_B);
1632 VariableMatrix<Scalar> X{detail::empty, A.cols(), B.cols()};
1633 for (
int row = 0; row < X.rows(); ++row) {
1634 for (
int col = 0; col < X.cols(); ++col) {
1635 X[row, col] = eigen_X[row, col];
1643extern template SLEIPNIR_DLLEXPORT VariableMatrix<double> solve(
1644 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:24
Definition variable_matrix.hpp:33
const_reverse_iterator crbegin() const
Definition variable_matrix.hpp:1171
VariableMatrix(std::initializer_list< std::initializer_list< Variable< Scalar > > > list)
Definition variable_matrix.hpp:73
const_reverse_iterator crend() const
Definition variable_matrix.hpp:1178
Scalar_ Scalar
Scalar type alias.
Definition variable_matrix.hpp:36
iterator end()
Definition variable_matrix.hpp:1122
const Variable< Scalar > & operator[](int row, int col) const
Definition variable_matrix.hpp:317
VariableMatrix(Variable< Scalar > &&variable)
Definition variable_matrix.hpp:194
const VariableBlock< const VariableMatrix > block(int row_offset, int col_offset, int block_rows, int block_cols) const
Definition variable_matrix.hpp:364
size_t size() const
Definition variable_matrix.hpp:1185
static VariableMatrix< Scalar > zero(int rows, int cols)
Definition variable_matrix.hpp:1192
VariableBlock< VariableMatrix > block(int row_offset, int col_offset, int block_rows, int block_cols)
Definition variable_matrix.hpp:348
VariableMatrix(const std::vector< std::vector< Scalar > > &list)
Definition variable_matrix.hpp:100
VariableMatrix & operator=(ScalarLike auto value)
Definition variable_matrix.hpp:278
VariableMatrix & operator-=(const MatrixLike auto &rhs)
Definition variable_matrix.hpp:896
Variable< Scalar > & operator[](int index)
Definition variable_matrix.hpp:327
VariableMatrix & operator=(const Eigen::MatrixBase< Derived > &values)
Definition variable_matrix.hpp:260
friend VariableMatrix< Scalar > operator-(const LHS &lhs, const RHS &rhs)
Definition variable_matrix.hpp:838
VariableMatrix & operator-=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:912
friend VariableMatrix< Scalar > operator*(const Variable< Scalar > &lhs, const RHS &rhs)
Definition variable_matrix.hpp:605
VariableMatrix & operator*=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:659
Scalar value(int index)
Definition variable_matrix.hpp:983
VariableMatrix(const VariableBlock< VariableMatrix > &values)
Definition variable_matrix.hpp:202
VariableMatrix(int rows, int cols)
Definition variable_matrix.hpp:51
const_iterator cbegin() const
Definition variable_matrix.hpp:1137
const_iterator begin() const
Definition variable_matrix.hpp:1127
const_iterator cend() const
Definition variable_matrix.hpp:1142
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > value()
Definition variable_matrix.hpp:988
const VariableBlock< const VariableMatrix > operator[](Slice row_slice, Slice col_slice) const
Definition variable_matrix.hpp:392
friend VariableMatrix< Scalar > operator/(const LHS &lhs, const Variable< Scalar > &rhs)
Definition variable_matrix.hpp:675
VariableMatrix(int rows)
Definition variable_matrix.hpp:45
VariableMatrix(std::span< const Variable< Scalar > > values, int rows, int cols)
Definition variable_matrix.hpp:244
VariableBlock< VariableMatrix > col(int col)
Definition variable_matrix.hpp:482
VariableMatrix(const Eigen::MatrixBase< Derived > &values)
Definition variable_matrix.hpp:151
const VariableBlock< const VariableMatrix > operator[](Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length) const
Definition variable_matrix.hpp:428
const VariableBlock< const VariableMatrix > col(int col) const
Definition variable_matrix.hpp:491
VariableMatrix & operator+=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:820
friend VariableMatrix< Scalar > operator*(const LHS &lhs, const Variable< Scalar > &rhs)
Definition variable_matrix.hpp:570
VariableBlock< VariableMatrix > segment(int offset, int length)
Definition variable_matrix.hpp:440
Scalar value(int row, int col)
Definition variable_matrix.hpp:977
const VariableBlock< const VariableMatrix > row(int row) const
Definition variable_matrix.hpp:473
VariableMatrix()=default
Constructs an empty VariableMatrix.
VariableMatrix & operator+=(const MatrixLike auto &rhs)
Definition variable_matrix.hpp:804
VariableMatrix(std::span< const Variable< Scalar > > values)
Definition variable_matrix.hpp:229
friend VariableMatrix< Scalar > operator-(const SleipnirMatrixLike< Scalar > auto &lhs)
Definition variable_matrix.hpp:927
static VariableMatrix< Scalar > constant(int rows, int cols, Scalar constant)
Definition variable_matrix.hpp:1223
VariableMatrix< Scalar > T() const
Definition variable_matrix.hpp:950
VariableMatrix< Scalar > cwise_transform(function_ref< Variable< Scalar >(const Variable< Scalar > &x)> unary_op) const
Definition variable_matrix.hpp:1005
friend VariableMatrix< Scalar > operator*(const LHS &lhs, const RHS &rhs)
Definition variable_matrix.hpp:501
const_reverse_iterator rbegin() const
Definition variable_matrix.hpp:1157
VariableMatrix(const Variable< Scalar > &variable)
Definition variable_matrix.hpp:186
reverse_iterator rend()
Definition variable_matrix.hpp:1152
VariableMatrix(const VariableBlock< const VariableMatrix > &values)
Definition variable_matrix.hpp:216
int rows() const
Definition variable_matrix.hpp:965
static VariableMatrix< Scalar > one(int rows, int cols)
Definition variable_matrix.hpp:1207
VariableMatrix(const Eigen::DiagonalBase< Derived > &values)
Definition variable_matrix.hpp:167
VariableBlock< VariableMatrix > operator[](Slice row_slice, Slice col_slice)
Definition variable_matrix.hpp:380
const_reverse_iterator rend() const
Definition variable_matrix.hpp:1164
VariableMatrix & operator*=(const MatrixLike auto &rhs)
Definition variable_matrix.hpp:639
VariableMatrix(detail::empty_t, int rows, int cols)
Definition variable_matrix.hpp:62
const_iterator end() const
Definition variable_matrix.hpp:1132
void set_value(const Eigen::MatrixBase< Derived > &values)
Definition variable_matrix.hpp:291
Variable< Scalar > & operator[](int row, int col)
Definition variable_matrix.hpp:306
iterator begin()
Definition variable_matrix.hpp:1117
const VariableBlock< const VariableMatrix > segment(int offset, int length) const
Definition variable_matrix.hpp:452
reverse_iterator rbegin()
Definition variable_matrix.hpp:1147
VariableBlock< VariableMatrix > row(int row)
Definition variable_matrix.hpp:464
friend VariableMatrix< Scalar > operator+(const LHS &lhs, const RHS &rhs)
Definition variable_matrix.hpp:746
VariableMatrix(const std::vector< std::vector< Variable< Scalar > > > &list)
Definition variable_matrix.hpp:126
VariableBlock< VariableMatrix > operator[](Slice row_slice, int row_slice_length, Slice col_slice, int col_slice_length)
Definition variable_matrix.hpp:410
VariableMatrix & operator/=(const ScalarLike auto &rhs)
Definition variable_matrix.hpp:730
const Variable< Scalar > & operator[](int index) const
Definition variable_matrix.hpp:336
int cols() const
Definition variable_matrix.hpp:970
Definition variable.hpp:47
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