Thea
IMatrix.hpp
1 //============================================================================
2 //
3 // This file is part of the Thea toolkit.
4 //
5 // This software is distributed under the BSD license, as detailed in the
6 // accompanying LICENSE.txt file. Portions are derived from other works:
7 // their respective licenses and copyright information are reproduced in
8 // LICENSE.txt and/or in the relevant source files.
9 //
10 // Author: Siddhartha Chaudhuri
11 // First version: 2009
12 //
13 //============================================================================
14 
15 #ifndef __Thea_IMatrix_hpp__
16 #define __Thea_IMatrix_hpp__
17 
18 #include "Common.hpp"
19 
20 namespace Thea {
21 
22 // Forward declarations
23 template <typename T> class IAddressableMatrix;
24 template <typename T> class ISparseMatrix;
25 
27 template <typename T>
28 class /* THEA_API */ IMatrix
29 {
30  public:
31  THEA_DECL_SMART_POINTERS(IMatrix)
32 
33  typedef T Value;
34  typedef T value_type;
35 
37  virtual ~IMatrix() {}
38 
40  virtual int64 THEA_ICALL rows() const = 0;
41 
43  virtual int64 THEA_ICALL cols() const = 0;
44 
46  virtual void THEA_ICALL setZero() = 0;
47 
49  virtual int8 THEA_ICALL isResizable() const = 0;
50 
58  virtual int8 THEA_ICALL resize(int64 nrows, int64 ncols) = 0;
59 
67  virtual IAddressableMatrix<T> const * THEA_ICALL asAddressable() const = 0;
68 
77 
85  virtual ISparseMatrix<T> const * THEA_ICALL asSparse() const = 0;
86 
94  virtual ISparseMatrix<T> * THEA_ICALL asSparse() = 0;
95 
96 }; // class IMatrix
97 
98 } // namespace Thea
99 
100 #endif
virtual int64 rows() const =0
Get the number of rows.
Interface for a 2D matrix, to allow passing matrices and vectors across shared library boundaries...
Definition: IMatrix.hpp:28
VertexMatrix::value_type Value
Type of values stored in the matrix.
Definition: IMatrix.hpp:33
Root namespace for the Thea library.
Interface for a 2D matrix with elements that may be directly accessed via a (row, column) pair...
Interface for a 2D sparse matrix.
Definition: IMatrix.hpp:24
virtual int64 cols() const =0
Get the number of columns.
virtual void setZero()=0
Set all elements to zero.
virtual int8 resize(int64 nrows, int64 ncols)=0
Resize the matrix to new dimensions, if isResizable() returns true.
virtual int8 isResizable() const =0
Check if the matrix can be freely resized.
VertexMatrix::value_type value_type
Type of values stored in the matrix (STL convention).
Definition: IMatrix.hpp:34
virtual IAddressableMatrix< T > const * asAddressable() const =0
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supp...
virtual ISparseMatrix< T > const * asSparse() const =0
If the matrix elements are addressable by (row, col) pairs, get a pointer to a derived interface supp...
#define THEA_ICALL
Calling convention for member functions of abstract interface classes (for talking to shared librarie...
Definition: Platform.hpp:115