StructuredG.h
Go to the documentation of this file.
1 /* Copyright 2020-2021 CNRS-AIST JRL */
2 
3 #pragma once
4 
5 #include <iosfwd>
6 #include <vector>
7 
8 #include <jrl-qp/api.h>
9 #include <jrl-qp/defs.h>
11 
12 namespace jrl::qp::structured
13 {
15 {
16 public:
17  enum class Type
18  {
19  TriBlockDiagonal,
20  BlockArrowUp,
21  BlockArrowDown
22  };
23 
24  StructuredG() = default;
25  StructuredG(Type t, const std::vector<MatrixRef> & diag, const std::vector<MatrixRef> & offDiag);
26 
27  Type type() const
28  {
29  return type_;
30  }
31 
32  const MatrixRef & diag(int i) const
33  {
34  return diag_[static_cast<size_t>(i)];
35  }
36 
37  const MatrixRef & offDiag(int i) const
38  {
39  return offDiag_[static_cast<size_t>(i)];
40  }
41 
42  int nbVar() const
43  {
44  return nbVar_;
45  }
46 
47  int nbVar(int i) const
48  {
49  return static_cast<int>(diag(i).cols());
50  }
51 
52  bool lltInPlace();
53  bool decomposed() const
54  {
55  return decomposed_;
56  }
57 
58  void solveInPlaceLTranspose(VectorRef v) const;
59  void solveL(VectorRef out, const VectorConstRef & in) const;
60  void solveL(VectorRef out, const internal::SingleNZSegmentVector & in) const;
61 
62  friend std::ostream & operator<<(std::ostream & os, const StructuredG & /*G*/)
63  {
64  // TODO
65  return os;
66  }
67 
68 private:
69  Type type_;
70  std::vector<MatrixRef> diag_;
71  std::vector<MatrixRef> offDiag_;
72  std::vector<int> start_;
73  int nbVar_ = 0;
74 
75  bool decomposed_ = false; // Whether this contains the original matrix or its llt decomposition
76 };
77 } // namespace jrl::qp::structured
jrl::qp::structured::StructuredG::diag
const MatrixRef & diag(int i) const
Definition: StructuredG.h:32
jrl::qp::structured::StructuredG::decomposed
bool decomposed() const
Definition: StructuredG.h:53
jrl::qp::VectorConstRef
Eigen::Ref< const Eigen::VectorXd > VectorConstRef
Definition: defs.h:13
SingleNZSegmentVector.h
jrl::qp::structured::StructuredG
Definition: StructuredG.h:14
jrl::qp::structured::StructuredG::Type
Type
Definition: StructuredG.h:17
jrl::qp::structured
Definition: StructuredC.h:13
jrl::qp::structured::StructuredG::nbVar
int nbVar(int i) const
Definition: StructuredG.h:47
jrl::qp::structured::StructuredG::nbVar
int nbVar() const
Definition: StructuredG.h:42
JRLQP_DLLAPI
#define JRLQP_DLLAPI
Definition: api.h:35
jrl::qp::internal::SingleNZSegmentVector
Definition: SingleNZSegmentVector.h:10
defs.h
jrl::qp::structured::StructuredG::type
Type type() const
Definition: StructuredG.h:27
jrl::qp::structured::StructuredG::operator<<
friend std::ostream & operator<<(std::ostream &os, const StructuredG &)
Definition: StructuredG.h:62
jrl::qp::VectorRef
Eigen::Ref< Eigen::VectorXd > VectorRef
Definition: defs.h:14
jrl::qp::MatrixRef
Eigen::Ref< Eigen::MatrixXd > MatrixRef
Definition: defs.h:12
jrl::qp::structured::StructuredG::offDiag
const MatrixRef & offDiag(int i) const
Definition: StructuredG.h:37
api.h