AGX Dynamics  2.37.3.2
SparseMatrixRepSabre.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #ifndef AGX_SPARSEMATRIXREPSABRE_H
18 #define AGX_SPARSEMATRIXREPSABRE_H
19 
20 #include <agx/config/AGX_USE_HDF5.h>
21 #include <agx/SparseMatrix.h>
22 #include <agxSabre/Sabre.h>
23 #include <agxSabre/SabreData.h>
24 
25 namespace agx
26 {
27 
29  {
30  public:
31  // constructor
33 
34  // Optional constructor that takes compressed matrix as input
35  SparseMatrixRepSabre( size_t* blkSizes, size_t numBlocks, size_t i, size_t j, size_t nnz, int* r, int* c, double* data );
36 
37  // destructor
38  virtual ~SparseMatrixRepSabre();
39 
40  virtual agx::Real* getBlock(int i, int j, bool& writeTransposed, unsigned int& ld) override;
41 
42  virtual void reset() override;
43 
44  virtual void factor() override;
45  virtual void solve( agx::Real* ) override;
46  virtual size_t unitSolve( agx::Real*, int startRow = -1 ) override;
47 
48  virtual void multiply( const agx::Real* x, agx::Real* r ) override;
49  virtual void multiplyAdd( const agx::Real* x, agx::Real* r ) override;
50  virtual void multiplyAdd( const agx::Real& alpha, const agx::Real* x, const agx::Real& beta, agx::Real* r ) override;
51 
52  virtual void setLogicalStructure( size_t n, const unsigned int* pointers, const unsigned int* indices, const unsigned int* dimensions, const int* flags, unsigned int numThreads ) override;
53 
54  virtual agx::Bool getRow( agx::UInt rowNumber, const agx::RealValarray& signs, agx::RealValarray& retRow ) const override;
55  virtual agx::Bool getColumn( agx::UInt colNumber, agx::RealValarray& retCol, agx::Bool& signFlip ) const override;
56 
57  virtual agx::UInt getBlockPermutedStartRowIndex( agx::UInt blockIndex ) const override;
58  virtual agx::UInt permuteRowIndex( agx::UInt rowIndex ) const override;
59  virtual agx::UInt invPermuteRowIndex( agx::UInt permutedRowIndex ) const override;
60 
61  virtual unsigned int getNumRows() const override;
62  virtual unsigned int getNumColumns() const override;
63 
64  virtual void print() const override;
65 
66  virtual void setNumBodies(size_t num) override;
67 
68  #if AGX_USE_HDF5()
69  virtual bool saveH5(void* group, const agx::String& name ) const override;
70  virtual bool loadH5(void* group, const agx::String& name ) override;
71  #endif
72 
73  virtual agx::Real getFactorTime() const override { return m_data.getFactorTime(); }
74  virtual agx::Real getSolveTime() const override { return m_data.getSolveTime(); }
75 
76  agxSabre::SabreData<agx::Real>& getSabreData() { return m_data; }
77  const agxSabre::SabreData<agx::Real>& getSabreData() const { return m_data; }
78 
79  private:
80  agxSabre::Sabre m_sabre;
81  agxSabre::SabreData<agx::Real> m_data;
82  };
83 
84 }
85 
86 #endif
virtual void multiply(const agx::Real *x, agx::Real *r) override
const agxSabre::SabreData< agx::Real > & getSabreData() const
virtual unsigned int getNumColumns() const override
virtual void print() const override
virtual bool saveH5(void *group, const agx::String &name) const
bool Bool
Definition: Integer.h:48
virtual agx::UInt getBlockPermutedStartRowIndex(agx::UInt blockIndex) const override
virtual agx::Real * getBlock(int i, int j, bool &writeTransposed, unsigned int &ld) override
virtual agx::UInt permuteRowIndex(agx::UInt rowIndex) const override
SparseMatrixRep.
Definition: SparseMatrix.h:34
virtual bool loadH5(void *group, const agx::String &name)
virtual void factor() override
virtual void multiplyAdd(const agx::Real *x, agx::Real *r) override
uint32_t UInt
Definition: Integer.h:34
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
virtual unsigned int getNumRows() const override
agxSabre::SabreData< agx::Real > & getSabreData()
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
virtual void solve(agx::Real *) override
virtual void setLogicalStructure(size_t n, const unsigned int *pointers, const unsigned int *indices, const unsigned int *dimensions, const int *flags, unsigned int numThreads) override
virtual agx::Real getSolveTime() const override
virtual void setNumBodies(size_t num) override
virtual size_t unitSolve(agx::Real *, int startRow=-1) override
virtual agx::Bool getRow(agx::UInt rowNumber, const agx::RealValarray &signs, agx::RealValarray &retRow) const override
virtual agx::Real getFactorTime() const override
double Real
Definition: Real.h:42
virtual agx::Bool getColumn(agx::UInt colNumber, agx::RealValarray &retCol, agx::Bool &signFlip) const override
virtual void reset() override
virtual agx::UInt invPermuteRowIndex(agx::UInt permutedRowIndex) const override