AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
MatrixTypes.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 MATRIX_TYPES_H
18#define MATRIX_TYPES_H
19
20namespace agx
21{
22
48 class MatrixType {
49 public:
50
61
76
77 MatrixType() : m_storage(DENSE), m_type(GENERIC) { }
78
79
80 MatrixType(int type, int storage) {
81 m_storage = storage;
82 m_type = type;
83 }
84
85 MatrixType & setSymmetric (bool t = true) {
86 (t)? m_type |= SYMMETRIC
87 : m_type &= ~SYMMETRIC;
88 return setGeneric(false);
89 }
90
91 MatrixType & setSquare (bool t = true) {
92 (t)? m_type |= SQUARE
93 : m_type &= ~SQUARE;
94 return setGeneric(false);
95 }
96
97 MatrixType & setSaddlePoint(bool t = true) {
98 (t)? m_type |= SADDLE_POINT
99 : m_type &= ~SADDLE_POINT;
100 return setGeneric(false).setSquare(true);
101 }
102
103 MatrixType & setPositiveDefinite (bool t = true) {
104 (t)? m_type |= POSITIVE_DEFINITE
105 : m_type &= ~POSITIVE_DEFINITE;
106 return setGeneric(!t).setSquare(true);
107 }
108
109 MatrixType & setGeneric (bool t = true ) {
110 if (t) { m_type = GENERIC ; }
111 return *this;
112 }
113
114 MatrixType &setDense(bool t = true ) {
115 (t)? m_storage |= DENSE
116 : m_storage &= ~DENSE;
117 return *this;
118 }
119
120 MatrixType &setSparse(bool t = true ) {
121 return setDense(!t);
122 }
123
124 MatrixType &setUpperTriangle(bool t = true ) {
125 (t)? m_storage |= UPPER_TRIANGLE
126 : m_storage &= ~UPPER_TRIANGLE;
127 return setLowerTriangle(!t);
128 }
129
130 MatrixType &setLowerTriangle(bool t = true ) {
131 (t)? m_storage |= LOWER_TRIANGLE
132 : m_storage &= ~LOWER_TRIANGLE;
133 return this->setSquare(true);
134 }
135
136 bool isGeneric() const { return m_type == GENERIC ; }
137 bool isPositiveDefinite () const { return (m_type&POSITIVE_DEFINITE) != 0; }
138 bool isSaddlePoint () const { return (m_type&SADDLE_POINT) != 0; }
139 bool isSymmetric () const { return (m_type&SYMMETRIC) != 0; }
140 bool isDense() const { return (m_storage&DENSE) != 0; }
141 bool isSparse() const { return ! isDense() ; }
142 bool isUpperTriangle() const { return (m_storage&UPPER_TRIANGLE) != 0; }
143 bool isLowerTriangle() const { return (m_storage&LOWER_TRIANGLE) != 0; }
144 bool isSquare() const { return (m_type&SQUARE) != 0; }
145
146 private:
147 int m_storage;
148 int m_type;
149 };
150
151}
152#endif
A class to distinguish between various types of matrices, both in terms of storage properties,...
Definition MatrixTypes.h:48
bool isPositiveDefinite() const
bool isSaddlePoint() const
Storage
How the matrix is stored.
Definition MatrixTypes.h:56
@ UPPER_TRIANGLE
Only upper triangle is stored, dense or sparse.
Definition MatrixTypes.h:58
@ DENSE
The entire matrix is stored, or it is sparse.
Definition MatrixTypes.h:57
@ LOWER_TRIANGLE
Only lower triangle is stored, dense or sparse.
Definition MatrixTypes.h:59
bool isUpperTriangle() const
bool isLowerTriangle() const
MatrixType & setGeneric(bool t=true)
bool isDense() const
bool isSymmetric() const
bool isSquare() const
MatrixType & setPositiveDefinite(bool t=true)
MatrixType & setSaddlePoint(bool t=true)
Definition MatrixTypes.h:97
Type
The kind of matrix we are dealing with.
Definition MatrixTypes.h:67
@ POSITIVE_DEFINITE
Positive definite matrices.
Definition MatrixTypes.h:71
@ SYMMETRIC
Symmetric matrices.
Definition MatrixTypes.h:70
@ GENERIC
No special property.
Definition MatrixTypes.h:68
@ SADDLE_POINT
Saddle point matrices, which may be symmetric or not, and positive definite or not.
Definition MatrixTypes.h:72
MatrixType & setSymmetric(bool t=true)
Definition MatrixTypes.h:85
MatrixType(int type, int storage)
Definition MatrixTypes.h:80
bool isSparse() const
MatrixType & setLowerTriangle(bool t=true)
MatrixType & setDense(bool t=true)
MatrixType & setUpperTriangle(bool t=true)
bool isGeneric() const
MatrixType & setSquare(bool t=true)
Definition MatrixTypes.h:91
MatrixType & setSparse(bool t=true)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.