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(); }
1218 gch::small_vector<Variable<Scalar>> m_storage;
1223template <
typename Derived>
1224VariableMatrix(
const Eigen::MatrixBase<Derived>&)
1225 -> VariableMatrix<typename Derived::Scalar>;
1227template <
typename Derived>
1228VariableMatrix(
const Eigen::DiagonalBase<Derived>&)
1229 -> VariableMatrix<typename Derived::Scalar>;
1237template <
typename Scalar>
1238VariableMatrix<Scalar> cwise_reduce(
1239 const VariableMatrix<Scalar>& lhs,
const VariableMatrix<Scalar>& rhs,
1240 function_ref<Variable<Scalar>(
const Variable<Scalar>& x,
1241 const Variable<Scalar>& y)>
1243 slp_assert(lhs.rows() == rhs.rows() && lhs.cols() == rhs.cols());
1245 VariableMatrix<Scalar> result{detail::empty, lhs.rows(), lhs.cols()};
1247 for (
int row = 0; row < lhs.rows(); ++row) {
1248 for (
int col = 0; col < lhs.cols(); ++col) {
1249 result[row, col] = binary_op(lhs[row, col], rhs[row, col]);
1265template <
typename Scalar>
1266VariableMatrix<Scalar> block(
1267 std::initializer_list<std::initializer_list<VariableMatrix<Scalar>>> list) {
1271 for (
const auto& row : list) {
1272 if (row.size() > 0) {
1273 rows += row.
begin()->rows();
1277 int latest_cols = 0;
1278 for (
const auto& elem : row) {
1280 slp_assert(row.begin()->rows() == elem.rows());
1282 latest_cols += elem.cols();
1290 slp_assert(cols == latest_cols);
1294 VariableMatrix<Scalar> result{detail::empty, rows, cols};
1297 for (
const auto& row : list) {
1299 for (
const auto& elem : row) {
1300 result.block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1301 col_offset += elem.cols();
1303 if (row.size() > 0) {
1304 row_offset += row.begin()->rows();
1322template <
typename Scalar>
1323VariableMatrix<Scalar> block(
1324 const std::vector<std::vector<VariableMatrix<Scalar>>>& list) {
1328 for (
const auto& row : list) {
1329 if (row.size() > 0) {
1330 rows += row.
begin()->rows();
1334 int latest_cols = 0;
1335 for (
const auto& elem : row) {
1337 slp_assert(row.begin()->rows() == elem.rows());
1339 latest_cols += elem.cols();
1347 slp_assert(cols == latest_cols);
1351 VariableMatrix<Scalar> result{detail::empty, rows, cols};
1354 for (
const auto& row : list) {
1356 for (
const auto& elem : row) {
1357 result.block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1358 col_offset += elem.cols();
1360 if (row.size() > 0) {
1361 row_offset += row.begin()->rows();
1374template <
typename Scalar>
1375VariableMatrix<Scalar> solve(
const VariableMatrix<Scalar>& A,
1376 const VariableMatrix<Scalar>& B) {
1378 slp_assert(A.rows() == B.rows());
1380 if (A.rows() == 1 && A.cols() == 1) {
1382 return B[0, 0] / A[0, 0];
1383 }
else if (A.rows() == 2 && A.cols() == 2) {
1389 const auto& a = A[0, 0];
1390 const auto& b = A[0, 1];
1391 const auto& c = A[1, 0];
1392 const auto& d = A[1, 1];
1394 VariableMatrix adj_A{{d, -b}, {-c, a}};
1395 auto det_A = a * d - b * c;
1396 return adj_A / det_A * B;
1397 }
else if (A.rows() == 3 && A.cols() == 3) {
1409 const auto& a = A[0, 0];
1410 const auto& b = A[0, 1];
1411 const auto& c = A[0, 2];
1412 const auto& d = A[1, 0];
1413 const auto& e = A[1, 1];
1414 const auto& f = A[1, 2];
1415 const auto& g = A[2, 0];
1416 const auto& h = A[2, 1];
1417 const auto& i = A[2, 2];
1438 auto adj_A00 = ei - fh;
1439 auto adj_A10 = fg - di;
1440 auto adj_A20 = dh - eg;
1442 VariableMatrix adj_A{{adj_A00, ch - bi, bf - ce},
1443 {adj_A10, ai - cg, cd - af},
1444 {adj_A20, bg - ah, ae - bd}};
1445 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20;
1446 return adj_A / det_A * B;
1447 }
else if (A.rows() == 4 && A.cols() == 4) {
1457 const auto& a = A[0, 0];
1458 const auto& b = A[0, 1];
1459 const auto& c = A[0, 2];
1460 const auto& d = A[0, 3];
1461 const auto& e = A[1, 0];
1462 const auto& f = A[1, 1];
1463 const auto& g = A[1, 2];
1464 const auto& h = A[1, 3];
1465 const auto& i = A[2, 0];
1466 const auto& j = A[2, 1];
1467 const auto& k = A[2, 2];
1468 const auto& l = A[2, 3];
1469 const auto& m = A[3, 0];
1470 const auto& n = A[3, 1];
1471 const auto& o = A[3, 2];
1472 const auto& p = A[3, 3];
1474 auto afk = a * f * k;
1475 auto afl = a * f * l;
1476 auto afo = a * f * o;
1477 auto afp = a * f * p;
1478 auto agj = a * g * j;
1479 auto agl = a * g * l;
1480 auto agn = a * g * n;
1481 auto agp = a * g * p;
1482 auto ahj = a * h * j;
1483 auto ahk = a * h * k;
1484 auto ahn = a * h * n;
1485 auto aho = a * h * o;
1486 auto ajo = a * j * o;
1487 auto ajp = a * j * p;
1488 auto akn = a * k * n;
1489 auto akp = a * k * p;
1490 auto aln = a * l * n;
1491 auto alo = a * l * o;
1492 auto bek = b * e * k;
1493 auto bel = b * e * l;
1494 auto beo = b * e * o;
1495 auto bep = b * e * p;
1496 auto bgi = b * g * i;
1497 auto bgl = b * g * l;
1498 auto bgm = b * g * m;
1499 auto bgp = b * g * p;
1500 auto bhi = b * h * i;
1501 auto bhk = b * h * k;
1502 auto bhm = b * h * m;
1503 auto bho = b * h * o;
1504 auto bio = b * i * o;
1505 auto bip = b * i * p;
1506 auto bjp = b * j * p;
1507 auto bkm = b * k * m;
1508 auto bkp = b * k * p;
1509 auto blm = b * l * m;
1510 auto blo = b * l * o;
1511 auto cej = c * e * j;
1512 auto cel = c * e * l;
1513 auto cen = c * e * n;
1514 auto cep = c * e * p;
1515 auto cfi = c * f * i;
1516 auto cfl = c * f * l;
1517 auto cfm = c * f * m;
1518 auto cfp = c * f * p;
1519 auto chi = c * h * i;
1520 auto chj = c * h * j;
1521 auto chm = c * h * m;
1522 auto chn = c * h * n;
1523 auto cin = c * i * n;
1524 auto cip = c * i * p;
1525 auto cjm = c * j * m;
1526 auto cjp = c * j * p;
1527 auto clm = c * l * m;
1528 auto cln = c * l * n;
1529 auto dej = d * e * j;
1530 auto dek = d * e * k;
1531 auto den = d * e * n;
1532 auto deo = d * e * o;
1533 auto dfi = d * f * i;
1534 auto dfk = d * f * k;
1535 auto dfm = d * f * m;
1536 auto dfo = d * f * o;
1537 auto dgi = d * g * i;
1538 auto dgj = d * g * j;
1539 auto dgm = d * g * m;
1540 auto dgn = d * g * n;
1541 auto din = d * i * n;
1542 auto dio = d * i * o;
1543 auto djm = d * j * m;
1544 auto djo = d * j * o;
1545 auto dkm = d * k * m;
1546 auto dkn = d * k * n;
1547 auto ejo = e * j * o;
1548 auto ejp = e * j * p;
1549 auto ekn = e * k * n;
1550 auto ekp = e * k * p;
1551 auto eln = e * l * n;
1552 auto elo = e * l * o;
1553 auto fio = f * i * o;
1554 auto fip = f * i * p;
1555 auto fkm = f * k * m;
1556 auto fkp = f * k * p;
1557 auto flm = f * l * m;
1558 auto flo = f * l * o;
1559 auto gin = g * i * n;
1560 auto gip = g * i * p;
1561 auto gjm = g * j * m;
1562 auto gjp = g * j * p;
1563 auto glm = g * l * m;
1564 auto gln = g * l * n;
1565 auto hin = h * i * n;
1566 auto hio = h * i * o;
1567 auto hjm = h * j * m;
1568 auto hjo = h * j * o;
1569 auto hkm = h * k * m;
1570 auto hkn = h * k * n;
1572 auto adj_A00 = fkp - flo - gjp + gln + hjo - hkn;
1573 auto adj_A01 = -bkp + blo + cjp - cln - djo + dkn;
1574 auto adj_A02 = bgp - bho - cfp + chn + dfo - dgn;
1575 auto adj_A03 = -bgl + bhk + cfl - chj - dfk + dgj;
1576 auto adj_A10 = -ekp + elo + gip - glm - hio + hkm;
1577 auto adj_A11 = akp - alo - cip + clm + dio - dkm;
1578 auto adj_A12 = -agp + aho + cep - chm - deo + dgm;
1579 auto adj_A13 = agl - ahk - cel + chi + dek - dgi;
1580 auto adj_A20 = ejp - eln - fip + flm + hin - hjm;
1581 auto adj_A21 = -ajp + aln + bip - blm - din + djm;
1582 auto adj_A22 = afp - ahn - bep + bhm + den - dfm;
1583 auto adj_A23 = -afl + ahj + bel - bhi - dej + dfi;
1584 auto adj_A30 = -ejo + ekn + fio - fkm - gin + gjm;
1586 auto adj_A31 = ajo - akn - bio + bkm + cin - cjm;
1587 auto adj_A32 = -afo + agn + beo - bgm - cen + cfm;
1588 auto adj_A33 = afk - agj - bek + bgi + cej - cfi;
1590 VariableMatrix adj_A{{adj_A00, adj_A01, adj_A02, adj_A03},
1591 {adj_A10, adj_A11, adj_A12, adj_A13},
1592 {adj_A20, adj_A21, adj_A22, adj_A23},
1593 {adj_A30, adj_A31, adj_A32, adj_A33}};
1594 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20 + d * adj_A30;
1595 return adj_A / det_A * B;
1598 Eigen::Matrix<Variable<Scalar>, Eigen::Dynamic, Eigen::Dynamic>;
1600 MatrixXv eigen_A{A.rows(), A.cols()};
1601 for (
int row = 0; row < A.rows(); ++row) {
1602 for (
int col = 0; col < A.cols(); ++col) {
1603 eigen_A[row, col] = A[row, col];
1607 MatrixXv eigen_B{B.rows(), B.cols()};
1608 for (
int row = 0; row < B.rows(); ++row) {
1609 for (
int col = 0; col < B.cols(); ++col) {
1610 eigen_B[row, col] = B[row, col];
1614 MatrixXv eigen_X = eigen_A.householderQr().solve(eigen_B);
1616 VariableMatrix<Scalar> X{detail::empty, A.cols(), B.cols()};
1617 for (
int row = 0; row < X.rows(); ++row) {
1618 for (
int col = 0; col < X.cols(); ++col) {
1619 X[row, col] = eigen_X[row, col];
1627extern template SLEIPNIR_DLLEXPORT VariableMatrix<double> solve(
1628 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.
static VariableMatrix< Scalar > ones(int rows, int cols)
Definition variable_matrix.hpp:1207
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
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
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