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) {
1230template <
typename Derived>
1234template <
typename Derived>
1244template <
typename Scalar>
1254 for (
int row = 0; row < lhs.
rows(); ++row) {
1255 for (
int col = 0; col < lhs.
cols(); ++col) {
1256 result(row, col) = binary_op(lhs(row, col), rhs(row, col));
1272template <
typename Scalar>
1278 for (
const auto& row : list) {
1279 if (row.size() > 0) {
1280 rows += row.begin()->rows();
1284 int latest_cols = 0;
1285 for (
const auto& elem : row) {
1287 slp_assert(row.begin()->rows() == elem.rows());
1289 latest_cols += elem.cols();
1304 for (
const auto& row : list) {
1306 for (
const auto& elem : row) {
1307 result.
block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1308 col_offset += elem.cols();
1310 if (row.size() > 0) {
1311 row_offset += row.begin()->rows();
1329template <
typename Scalar>
1335 for (
const auto& row : list) {
1336 if (row.size() > 0) {
1337 rows += row.begin()->rows();
1341 int latest_cols = 0;
1342 for (
const auto& elem : row) {
1344 slp_assert(row.begin()->rows() == elem.rows());
1346 latest_cols += elem.cols();
1361 for (
const auto& row : list) {
1363 for (
const auto& elem : row) {
1364 result.
block(row_offset, col_offset, elem.rows(), elem.cols()) = elem;
1365 col_offset += elem.cols();
1367 if (row.size() > 0) {
1368 row_offset += row.begin()->rows();
1381template <
typename Scalar>
1387 if (A.
rows() == 1 && A.
cols() == 1) {
1389 return B(0, 0) / A(0, 0);
1390 }
else if (A.
rows() == 2 && A.
cols() == 2) {
1396 const auto& a = A(0, 0);
1397 const auto& b = A(0, 1);
1398 const auto& c = A(1, 0);
1399 const auto& d = A(1, 1);
1402 auto det_A = a * d - b * c;
1403 return adj_A / det_A * B;
1404 }
else if (A.
rows() == 3 && A.
cols() == 3) {
1416 const auto& a = A(0, 0);
1417 const auto& b = A(0, 1);
1418 const auto& c = A(0, 2);
1419 const auto& d = A(1, 0);
1420 const auto& e = A(1, 1);
1421 const auto& f = A(1, 2);
1422 const auto& g = A(2, 0);
1423 const auto& h = A(2, 1);
1424 const auto& i = A(2, 2);
1445 auto adj_A00 = ei - fh;
1446 auto adj_A10 =
fg - di;
1447 auto adj_A20 = dh - eg;
1450 {adj_A10, ai - cg, cd - af},
1451 {adj_A20,
bg - ah, ae - bd}};
1452 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20;
1453 return adj_A / det_A * B;
1454 }
else if (A.
rows() == 4 && A.
cols() == 4) {
1464 const auto& a = A(0, 0);
1465 const auto& b = A(0, 1);
1466 const auto& c = A(0, 2);
1467 const auto& d = A(0, 3);
1468 const auto& e = A(1, 0);
1469 const auto& f = A(1, 1);
1470 const auto& g = A(1, 2);
1471 const auto& h = A(1, 3);
1472 const auto& i = A(2, 0);
1473 const auto& j = A(2, 1);
1474 const auto& k = A(2, 2);
1475 const auto& l = A(2, 3);
1476 const auto& m = A(3, 0);
1477 const auto& n = A(3, 1);
1478 const auto& o = A(3, 2);
1479 const auto&
p = A(3, 3);
1481 auto afk = a * f * k;
1482 auto afl = a * f * l;
1483 auto afo = a * f * o;
1484 auto afp = a * f *
p;
1485 auto agj = a * g * j;
1486 auto agl = a * g * l;
1487 auto agn = a * g * n;
1488 auto agp = a * g *
p;
1489 auto ahj = a * h * j;
1490 auto ahk = a * h * k;
1491 auto ahn = a * h * n;
1492 auto aho = a * h * o;
1493 auto ajo = a * j * o;
1494 auto ajp = a * j *
p;
1495 auto akn = a * k * n;
1496 auto akp = a * k *
p;
1497 auto aln = a * l * n;
1498 auto alo = a * l * o;
1499 auto bek = b * e * k;
1500 auto bel = b * e * l;
1501 auto beo = b * e * o;
1502 auto bep = b * e *
p;
1503 auto bgi = b * g * i;
1504 auto bgl = b * g * l;
1505 auto bgm = b * g * m;
1506 auto bgp = b * g *
p;
1507 auto bhi = b * h * i;
1508 auto bhk = b * h * k;
1509 auto bhm = b * h * m;
1510 auto bho = b * h * o;
1511 auto bio = b * i * o;
1512 auto bip = b * i *
p;
1513 auto bjp = b * j *
p;
1514 auto bkm = b * k * m;
1515 auto bkp = b * k *
p;
1516 auto blm = b * l * m;
1517 auto blo = b * l * o;
1518 auto cej = c * e * j;
1519 auto cel = c * e * l;
1520 auto cen = c * e * n;
1521 auto cep = c * e *
p;
1522 auto cfi = c * f * i;
1523 auto cfl = c * f * l;
1524 auto cfm = c * f * m;
1525 auto cfp = c * f *
p;
1526 auto chi = c * h * i;
1527 auto chj = c * h * j;
1528 auto chm = c * h * m;
1529 auto chn = c * h * n;
1530 auto cin = c * i * n;
1531 auto cip = c * i *
p;
1532 auto cjm = c * j * m;
1533 auto cjp = c * j *
p;
1534 auto clm = c * l * m;
1535 auto cln = c * l * n;
1536 auto dej = d * e * j;
1537 auto dek = d * e * k;
1538 auto den = d * e * n;
1539 auto deo = d * e * o;
1540 auto dfi = d * f * i;
1541 auto dfk = d * f * k;
1542 auto dfm = d * f * m;
1543 auto dfo = d * f * o;
1544 auto dgi = d * g * i;
1545 auto dgj = d * g * j;
1546 auto dgm = d * g * m;
1547 auto dgn = d * g * n;
1548 auto din = d * i * n;
1549 auto dio = d * i * o;
1550 auto djm = d * j * m;
1551 auto djo = d * j * o;
1552 auto dkm = d * k * m;
1553 auto dkn = d * k * n;
1554 auto ejo = e * j * o;
1555 auto ejp = e * j *
p;
1556 auto ekn = e * k * n;
1557 auto ekp = e * k *
p;
1558 auto eln = e * l * n;
1559 auto elo = e * l * o;
1560 auto fio = f * i * o;
1561 auto fip = f * i *
p;
1562 auto fkm = f * k * m;
1563 auto fkp = f * k *
p;
1564 auto flm = f * l * m;
1565 auto flo = f * l * o;
1566 auto gin = g * i * n;
1567 auto gip = g * i *
p;
1568 auto gjm = g * j * m;
1569 auto gjp = g * j *
p;
1570 auto glm = g * l * m;
1571 auto gln = g * l * n;
1572 auto hin = h * i * n;
1573 auto hio = h * i * o;
1574 auto hjm = h * j * m;
1575 auto hjo = h * j * o;
1576 auto hkm = h * k * m;
1577 auto hkn = h * k * n;
1579 auto adj_A00 = fkp - flo - gjp + gln + hjo - hkn;
1580 auto adj_A01 = -bkp + blo + cjp - cln - djo + dkn;
1581 auto adj_A02 = bgp - bho - cfp + chn + dfo - dgn;
1582 auto adj_A03 = -bgl + bhk + cfl - chj - dfk + dgj;
1583 auto adj_A10 = -ekp + elo + gip - glm - hio + hkm;
1584 auto adj_A11 = akp - alo - cip + clm + dio - dkm;
1585 auto adj_A12 = -agp + aho + cep - chm - deo + dgm;
1586 auto adj_A13 = agl - ahk - cel + chi + dek - dgi;
1587 auto adj_A20 = ejp - eln - fip + flm + hin - hjm;
1588 auto adj_A21 = -ajp + aln + bip - blm - din + djm;
1589 auto adj_A22 = afp - ahn - bep + bhm + den - dfm;
1590 auto adj_A23 = -afl + ahj + bel - bhi - dej + dfi;
1591 auto adj_A30 = -ejo + ekn + fio - fkm - gin + gjm;
1593 auto adj_A31 = ajo - akn - bio + bkm + cin - cjm;
1594 auto adj_A32 = -afo + agn + beo - bgm - cen + cfm;
1595 auto adj_A33 = afk - agj - bek + bgi + cej - cfi;
1598 {adj_A10, adj_A11, adj_A12, adj_A13},
1599 {adj_A20, adj_A21, adj_A22, adj_A23},
1600 {adj_A30, adj_A31, adj_A32, adj_A33}};
1601 auto det_A = a * adj_A00 + b * adj_A10 + c * adj_A20 + d * adj_A30;
1602 return adj_A / det_A * B;
1605 Eigen::Matrix<Variable<Scalar>, Eigen::Dynamic, Eigen::Dynamic>;
1607 MatrixXv eigen_A{A.
rows(), A.
cols()};
1608 for (
int row = 0; row < A.
rows(); ++row) {
1609 for (
int col = 0; col < A.
cols(); ++col) {
1610 eigen_A(row, col) = A(row, col);
1614 MatrixXv eigen_B{B.rows(), B.cols()};
1615 for (
int row = 0; row < B.rows(); ++row) {
1616 for (
int col = 0; col < B.cols(); ++col) {
1617 eigen_B(row, col) = B(row, col);
1621 MatrixXv eigen_X = eigen_A.householderQr().solve(eigen_B);
1624 for (
int row = 0; row < X.
rows(); ++row) {
1625 for (
int col = 0; col < X.
cols(); ++col) {
1626 X(row, col) = eigen_X(row, col);
#define slp_assert(condition)
Abort 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.
static VariableMatrix< Scalar > ones(int rows, int cols)
Returns a variable matrix filled with ones.
Definition variable_matrix.hpp:1214
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
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
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 expression_graph.hpp:11
VariableMatrix< Scalar > solve(const VariableMatrix< Scalar > &A, const VariableMatrix< Scalar > &B)
Solves the VariableMatrix equation AX = B for X.
Definition variable_matrix.hpp:1382
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:1245
VariableMatrix(const Eigen::MatrixBase< Derived > &) -> VariableMatrix< typename Derived::Scalar >
VariableMatrix< Scalar > block(std::initializer_list< std::initializer_list< VariableMatrix< Scalar > > > list)
Assemble a VariableMatrix from a nested list of blocks.
Definition variable_matrix.hpp:1273
Type tag used to designate an uninitialized VariableMatrix.
Definition empty.hpp:8
#define SLEIPNIR_DLLEXPORT
Definition symbol_exports.hpp:34