23template <
typename Mat>
38 if (m_mat ==
nullptr) {
40 m_rowSlice =
values.m_rowSlice;
41 m_rowSliceLength =
values.m_rowSliceLength;
42 m_colSlice =
values.m_colSlice;
43 m_colSliceLength =
values.m_colSliceLength;
48 for (
int row = 0; row <
Rows(); ++row) {
70 if (m_mat ==
nullptr) {
72 m_rowSlice =
values.m_rowSlice;
73 m_rowSliceLength =
values.m_rowSliceLength;
74 m_colSlice =
values.m_colSlice;
75 m_colSliceLength =
values.m_colSliceLength;
80 for (
int row = 0; row <
Rows(); ++row) {
98 m_rowSliceLength{m_rowSlice.Adjust(
mat.
Rows())},
100 m_colSliceLength{m_colSlice.Adjust(
mat.
Cols())} {}
115 m_rowSliceLength{m_rowSlice.Adjust(
mat.
Rows())},
117 m_colSliceLength{m_colSlice.Adjust(
mat.
Cols())} {}
146 (*this)(0, 0) = value;
169 template <
typename Derived>
174 for (
int row = 0; row <
Rows(); ++row) {
188 template <
typename Derived>
189 requires std::same_as<typename Derived::Scalar, double>
194 for (
int row = 0; row <
Rows(); ++row) {
210 for (
int row = 0; row <
Rows(); ++row) {
227 for (
int row = 0; row <
Rows(); ++row) {
242 requires(!std::is_const_v<Mat>)
246 return (*m_mat)(m_rowSlice.
start + row * m_rowSlice.
step,
259 return (*m_mat)(m_rowSlice.
start + row * m_rowSlice.
step,
269 requires(!std::is_const_v<Mat>)
272 return (*
this)(row /
Cols(), row %
Cols());
282 return (*
this)(row /
Cols(), row %
Cols());
479 for (
int i = 0;
i <
Rows(); ++
i) {
480 for (
int j = 0;
j <
rhs.Cols(); ++
j) {
482 for (
int k = 0;
k <
Cols(); ++
k) {
499 for (
int row = 0; row <
Rows(); ++row) {
517 for (
int row = 0; row <
Rows(); ++row) {
519 (*this)(row,
col) /=
rhs(0, 0);
533 for (
int row = 0; row <
Rows(); ++row) {
548 for (
int row = 0; row <
Rows(); ++row) {
563 for (
int row = 0; row <
Rows(); ++row) {
575 std::remove_cv_t<Mat>
T()
const {
578 for (
int row = 0; row <
Rows(); ++row) {
590 int Rows()
const {
return m_rowSliceLength; }
595 int Cols()
const {
return m_colSliceLength; }
606 return (*m_mat)(m_rowSlice.
start + row * m_rowSlice.
step,
627 for (
int row = 0; row <
Rows(); ++row) {
645 for (
int row = 0; row <
Rows(); ++row) {
690 : m_mat{
mat}, m_index{index} {}
745 Mat* m_mat =
nullptr;
748 int m_rowSliceLength = 0;
751 int m_colSliceLength = 0;
#define Assert(condition)
Definition Assert.hpp:24
int step
Step.
Definition Slice.hpp:30
int start
Start index (inclusive).
Definition Slice.hpp:24
Definition VariableBlock.hpp:681
const_iterator(const VariableBlock< Mat > *mat, int index)
Definition VariableBlock.hpp:689
const_reference operator*() const
Definition VariableBlock.hpp:702
const_iterator operator++(int)
Definition VariableBlock.hpp:696
bool operator==(const const_iterator &) const =default
std::ptrdiff_t difference_type
Definition VariableBlock.hpp:685
const_iterator & operator++()
Definition VariableBlock.hpp:692
std::forward_iterator_tag iterator_category
Definition VariableBlock.hpp:683
Definition VariableBlock.hpp:654
reference operator*()
Definition VariableBlock.hpp:674
bool operator==(const iterator &) const =default
std::forward_iterator_tag iterator_category
Definition VariableBlock.hpp:656
std::ptrdiff_t difference_type
Definition VariableBlock.hpp:658
iterator(VariableBlock< Mat > *mat, int index)
Definition VariableBlock.hpp:662
iterator & operator++()
Definition VariableBlock.hpp:664
iterator operator++(int)
Definition VariableBlock.hpp:668
Definition VariableBlock.hpp:24
int Rows() const
Definition VariableBlock.hpp:590
VariableBlock< const Mat > Col(int col) const
Definition VariableBlock.hpp:466
const VariableBlock< const Mat > Block(int rowOffset, int colOffset, int blockRows, int blockCols) const
Definition VariableBlock.hpp:311
const_iterator cend() const
Definition VariableBlock.hpp:737
const VariableBlock< const Mat > operator()(Slice rowSlice, Slice colSlice) const
Definition VariableBlock.hpp:346
const_iterator end() const
Definition VariableBlock.hpp:727
iterator begin()
Definition VariableBlock.hpp:712
void SetValue(double value)
Definition VariableBlock.hpp:158
VariableBlock(const VariableBlock< Mat > &values)=default
VariableBlock< const Mat > Row(int row) const
Definition VariableBlock.hpp:446
VariableBlock< Mat > & operator/=(const VariableBlock< Mat > &rhs)
Definition VariableBlock.hpp:514
VariableBlock< Mat > Row(int row)
Definition VariableBlock.hpp:436
iterator end()
Definition VariableBlock.hpp:717
size_t size() const
Definition VariableBlock.hpp:742
VariableBlock(Mat &mat)
Definition VariableBlock.hpp:95
VariableBlock & operator*=(double rhs)
Definition VariableBlock.hpp:498
VariableBlock< Mat > & operator-=(const VariableBlock< Mat > &rhs)
Definition VariableBlock.hpp:562
void SetValue(const Eigen::MatrixBase< Derived > &values)
Definition VariableBlock.hpp:190
const VariableBlock< Mat > Segment(int offset, int length) const
Definition VariableBlock.hpp:425
int Cols() const
Definition VariableBlock.hpp:595
VariableBlock< Mat > & operator=(const Eigen::MatrixBase< Derived > &values)
Definition VariableBlock.hpp:170
const Variable & operator()(int row) const
Definition VariableBlock.hpp:280
VariableBlock< Mat > & operator=(VariableBlock< Mat > &&values)
Definition VariableBlock.hpp:65
const Variable & operator()(int row, int col) const
Definition VariableBlock.hpp:256
VariableBlock< Mat > & operator=(double value)
Definition VariableBlock.hpp:143
VariableBlock< Mat > & operator/=(double rhs)
Definition VariableBlock.hpp:532
std::remove_cv_t< Mat > T() const
Definition VariableBlock.hpp:575
Variable & operator()(int row)
Definition VariableBlock.hpp:268
const_iterator begin() const
Definition VariableBlock.hpp:722
VariableBlock(Mat &mat, Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
Definition VariableBlock.hpp:130
const_iterator cbegin() const
Definition VariableBlock.hpp:732
VariableBlock< Mat > operator()(Slice rowSlice, Slice colSlice)
Definition VariableBlock.hpp:327
Variable & operator()(int row, int col)
Definition VariableBlock.hpp:241
VariableBlock< Mat > & operator=(const VariableBlock< Mat > &values)
Definition VariableBlock.hpp:33
double Value(int row, int col)
Definition VariableBlock.hpp:603
VariableBlock< Mat > Col(int col)
Definition VariableBlock.hpp:456
VariableBlock< Mat > & operator=(Mat &&values)
Definition VariableBlock.hpp:223
VariableBlock< Mat > Block(int rowOffset, int colOffset, int blockRows, int blockCols)
Definition VariableBlock.hpp:293
Eigen::MatrixXd Value()
Definition VariableBlock.hpp:624
VariableBlock< Mat > & operator*=(const VariableBlock< Mat > &rhs)
Definition VariableBlock.hpp:476
VariableBlock< Mat > Segment(int offset, int length)
Definition VariableBlock.hpp:413
VariableBlock< Mat > & operator+=(const VariableBlock< Mat > &rhs)
Definition VariableBlock.hpp:547
const VariableBlock< const Mat > operator()(Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength) const
Definition VariableBlock.hpp:394
std::remove_cv_t< Mat > CwiseTransform(function_ref< Variable(const Variable &x)> unaryOp) const
Definition VariableBlock.hpp:641
double Value(int index)
Definition VariableBlock.hpp:616
VariableBlock< Mat > & operator=(const Mat &values)
Definition VariableBlock.hpp:206
VariableBlock(VariableBlock< Mat > &&)=default
VariableBlock(Mat &mat, int rowOffset, int colOffset, int blockRows, int blockCols)
Definition VariableBlock.hpp:111
VariableBlock< Mat > operator()(Slice rowSlice, int rowSliceLength, Slice colSlice, int colSliceLength)
Definition VariableBlock.hpp:371
Definition Variable.hpp:33
Definition FunctionRef.hpp:17
Definition Expression.hpp:18
IntrusiveSharedPtr< T > AllocateIntrusiveShared(Alloc alloc, Args &&... args)
Definition IntrusiveSharedPtr.hpp:275