AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
SparseInverse.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_SPARSE_INVERSE_H
18#define AGX_SPARSE_INVERSE_H
19
21#include <agx/IndexSet.h>
22#include <agx/SparseMatrix.h>
23#include <map>
24
25#include <agxSabre/DenseTypes.h>
26
27#ifdef _MSC_VER
28# pragma warning(push)
29// Disable warning about assignment operator could not be generated due to reference members.
30#pragma warning( disable: 4512 )
31#endif
32
33
34namespace agx
35{
36
58 class RealEntry : public std::pair<int, Real> {
59 public:
60 RealEntry() : std::pair<int, Real>() {}
61 RealEntry(const int& i, const Real &x) : std::pair<int, Real> (i, x) {}
62 bool operator< (const RealEntry & e) { return first < e.first ; }
63 bool operator== (const RealEntry & e) { return first == e.first ; }
64 bool operator<= (const RealEntry & e) { return first <= e.first ; }
65 };
66
72 class SparseVector : public Vector<RealEntry> {
73 public:
75 SparseVector(const RealValarray &x, const SparseRangeReal &bounds, Real threshold = 0 );
77 };
78
79
81 private:
82 typedef std::map<UInt, SparseVector > ISVMap;
83 ISVMap m_map;
84 void update_inverse( SparseMatrix& sparseMatrix, const IndexSet::IxSet& s, const SparseRangeReal& bounds, const RealValarray& signs );
85 void build_submatrix( SparseMatrix& sparseMatrix, const IndexSet::IxSet &s, const SparseRangeReal& bounds, agxSabre::DenseMatrix<agx::Real> &m, const RealValarray& signs );
86 public:
89
90 void clear();
91 void solve_subproblem( SparseMatrix& sparseMatrix, const IndexSet::IxSet& s, const SparseRangeReal& bounds, RealValarray &b, const RealValarray& signs );
92 };
93
94}
95
96#ifdef _MSC_VER
97# pragma warning(pop)
98#endif
99
100#endif
SparseInverse holds a subset of the columns of the inverse of a given sparse matrix.
RealEntry(const int &i, const Real &x)
bool operator<(const RealEntry &e)
bool operator==(const RealEntry &e)
bool operator<=(const RealEntry &e)
void solve_subproblem(SparseMatrix &sparseMatrix, const IndexSet::IxSet &s, const SparseRangeReal &bounds, RealValarray &b, const RealValarray &signs)
agx::SparseMatrix holds a matrix representation which contains the data.
Essentially a sparse array of bounds.
Definition SparseTypes.h:74
A sparse vector here is an Vector of entries with a few additional operations for creation and sortin...
SparseVector(const RealValarray &x, const SparseRangeReal &bounds, Real threshold=0)
void extract_subvector(const IndexSet::IxSet &s, SparseVector &V) const
Templated vector class.
Definition agx/Vector.h:53
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition Real.h:42
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
STL namespace.