SmartEngine  1.6.0
Matrix.h
1 // Copyright (C) Entropy Software LLC - All Rights Reserved
2 
3 #pragma once
4 
5 #include "Object.h"
6 #include "StrongNumber.h"
7 
8 namespace SmartEngine
9 {
10 
12 
16 class SMARTENGINE_EXPORT IMatrix : public virtual IObject
17 {
18 public:
19  SMARTENGINE_DECLARE_CLASS(IMatrix)
20 
21 
22  virtual bool IsReadOnly() const = 0;
25 
29  virtual MatrixIndex RowCount() const = 0;
30 
34  virtual MatrixIndex ColCount() const = 0;
35 
39  virtual float GetValue(MatrixIndex row, MatrixIndex col) const = 0;
40 
46  virtual void GetRow(MatrixIndex row, float* buffer, MatrixIndex bufferCount) const = 0;
47 
54  virtual void GetBuffer(float* buffer, MatrixIndex bufferCount) const = 0;
55 
59  virtual void SetValue(MatrixIndex row, MatrixIndex col, float value) = 0;
60 
65  virtual void Resize(MatrixIndex rows, MatrixIndex cols) = 0;
66 
70  virtual void Zero() = 0;
71 
75  virtual bool HasNaN() = 0;
76 };
77 
81 SMARTENGINE_EXPORT ObjectPtr<IMatrix> CreateMatrix(MatrixIndex rows, MatrixIndex cols);
82 
84 extern "C"
85 {
86  SMARTENGINE_EXPORT ObjPtr Matrix_CreateInstance(int64 rows, int64 cols);
87  SMARTENGINE_EXPORT int Matrix_IsReadOnly(ObjPtr object);
88  SMARTENGINE_EXPORT int64 Matrix_RowCount(ObjPtr object);
89  SMARTENGINE_EXPORT int64 Matrix_ColCount(ObjPtr object);
90  SMARTENGINE_EXPORT float Matrix_GetValue(ObjPtr object, int64 row, int64 col);
91  SMARTENGINE_EXPORT void Matrix_GetRow(ObjPtr object, int64 row, float* buffer, int64 bufferCount);
92  SMARTENGINE_EXPORT void Matrix_GetBuffer(ObjPtr object, float* buffer, int64 bufferCount);
93  SMARTENGINE_EXPORT void Matrix_SetValue(ObjPtr object, int64 row, int64 col, float value);
94  SMARTENGINE_EXPORT void Matrix_Resize(ObjPtr object, int64 rows, int64 cols);
95  SMARTENGINE_EXPORT void Matrix_Zero(ObjPtr object);
96  SMARTENGINE_EXPORT int Matrix_HasNaN(ObjPtr object);
97 }
99 
100 } // namespace SmartEngine
SmartEngine::IMatrix::ColCount
virtual MatrixIndex ColCount() const =0
Returns the number of columns in the matrix
SmartEngine::IMatrix::Resize
virtual void Resize(MatrixIndex rows, MatrixIndex cols)=0
Resizes the matrix to the specified number of rows and columns. This will error if the matrix is read...
SmartEngine::StrongNumber
Definition: StrongNumber.h:9
SmartEngine::IMatrix::GetBuffer
virtual void GetBuffer(float *buffer, MatrixIndex bufferCount) const =0
Fills the buffer with all elements from this matrix. The elements in the buffer will be laid out in r...
SmartEngine::CreateMatrix
SMARTENGINE_EXPORT ObjectPtr< IMatrix > CreateMatrix(MatrixIndex rows, MatrixIndex cols)
Creates an instance of IMatrix
SmartEngine::IMatrix::SetValue
virtual void SetValue(MatrixIndex row, MatrixIndex col, float value)=0
Sets a value in the matrix. This will error if the matrix is read only.
SmartEngine::ObjectPtr
Smart pointer to an IObject. Automatic ref counting.
Definition: ObjectPtr.h:16
SmartEngine::IMatrix::GetRow
virtual void GetRow(MatrixIndex row, float *buffer, MatrixIndex bufferCount) const =0
Fills the buffer with a single row from the matrix. The buffer should have space for at least RowCoun...
SmartEngine
Definition: A2CTrainer.h:10
SmartEngine::IObject
Base class for SmartEngine AI objects. It is not common to deal with this class directly.
Definition: Object.h:19
SmartEngine::IMatrix::Zero
virtual void Zero()=0
Assigns 0 to all values in the matrix.
SmartEngine::IMatrix
Wrapper around either a const or a mutable matrix.
Definition: Matrix.h:17
SmartEngine::IMatrix::GetValue
virtual float GetValue(MatrixIndex row, MatrixIndex col) const =0
Returns the value at location [row, col]
SmartEngine::IMatrix::RowCount
virtual MatrixIndex RowCount() const =0
Returns the number of rows in the matrix
SmartEngine::IMatrix::HasNaN
virtual bool HasNaN()=0
Returns true if any value is NaN, false otherwise.