AGXDynamics  2.35.0.2
SparseMatrixRepSabre.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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
agx::Real
double Real
Definition: Real.h:42
agx::SparseMatrixRepSabre::getBlock
virtual agx::Real * getBlock(int i, int j, bool &writeTransposed, unsigned int &ld) override
agx::SparseMatrixRepSabre::getSabreData
const agxSabre::SabreData< agx::Real > & getSabreData() const
Definition: SparseMatrixRepSabre.h:77
agx::SparseMatrixRepSabre::solve
virtual void solve(agx::Real *) override
agx::SparseMatrixRepSabre::multiply
virtual void multiply(const agx::Real *x, agx::Real *r) override
agx::SparseMatrixRepSabre::permuteRowIndex
virtual agx::UInt permuteRowIndex(agx::UInt rowIndex) const override
agx::SparseMatrixRepSabre::getNumColumns
virtual unsigned int getNumColumns() const override
agx::SparseMatrixRepSabre
Definition: SparseMatrixRepSabre.h:28
SparseMatrix.h
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
agx::SparseMatrixRepSabre::getSolveTime
virtual agx::Real getSolveTime() const override
Definition: SparseMatrixRepSabre.h:74
agx::SparseMatrixRepSabre::multiplyAdd
virtual void multiplyAdd(const agx::Real *x, agx::Real *r) override
agx::SparseMatrixRepSabre::getBlockPermutedStartRowIndex
virtual agx::UInt getBlockPermutedStartRowIndex(agx::UInt blockIndex) const override
agx::SparseMatrixRepSabre::getFactorTime
virtual agx::Real getFactorTime() const override
Definition: SparseMatrixRepSabre.h:73
agx::SparseMatrixRepSabre::getNumRows
virtual unsigned int getNumRows() const override
agx::SparseMatrixRepSabre::reset
virtual void reset() override
agx::SparseMatrixRepSabre::setLogicalStructure
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
agx::SparseMatrixRepSabre::invPermuteRowIndex
virtual agx::UInt invPermuteRowIndex(agx::UInt permutedRowIndex) const override
agx::RealValarray
std::valarray< agx::Real > RealValarray
For this module, vectors are defined using valarray.
Definition: agx_valarray_types.h:27
agx::SparseMatrixRep::saveH5
virtual bool saveH5(void *group, const agx::String &name) const
agx::SparseMatrixRepSabre::setNumBodies
virtual void setNumBodies(size_t num) override
agx::SparseMatrixRepSabre::getRow
virtual agx::Bool getRow(agx::UInt rowNumber, const agx::RealValarray &signs, agx::RealValarray &retRow) const override
agx::SparseMatrixRepSabre::factor
virtual void factor() override
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agx::SparseMatrixRepSabre::getColumn
virtual agx::Bool getColumn(agx::UInt colNumber, agx::RealValarray &retCol, agx::Bool &signFlip) const override
agx::Bool
bool Bool
Definition: Integer.h:48
agx::SparseMatrixRep::loadH5
virtual bool loadH5(void *group, const agx::String &name)
agx::AgXString< std::string >
agx::SparseMatrixRepSabre::unitSolve
virtual size_t unitSolve(agx::Real *, int startRow=-1) override
agx::SparseMatrixRepSabre::SparseMatrixRepSabre
SparseMatrixRepSabre()
agx::SparseMatrixRepSabre::~SparseMatrixRepSabre
virtual ~SparseMatrixRepSabre()
agx::SparseMatrixRepSabre::getSabreData
agxSabre::SabreData< agx::Real > & getSabreData()
Definition: SparseMatrixRepSabre.h:76
agx::SparseMatrixRepSabre::print
virtual void print() const override
agx::SparseMatrixRep
SparseMatrixRep.
Definition: SparseMatrix.h:34