Honeycomb  0.1
Component-Model Framework
Matrix.h
Go to the documentation of this file.
1 // Honeycomb, Copyright (C) 2015 NewGamePlus Inc. Distributed under the Boost Software License v1.0.
2 #pragma once
3 
5 
6 namespace honey
7 {
8 
10 template<sdt Rows, sdt Cols, class Real_, int Options, class Alloc_>
11 struct matrix::priv::Traits<Matrix<Rows,Cols,Real_,Options,Alloc_>>
12 {
14  typedef Real_ Real;
15  typedef Real ElemT;
16  static const sdt rows = Rows;
17  static const sdt cols = Cols;
18  static const int options = Options;
19  typedef Alloc_ Alloc;
20 };
21 
23 template<sdt Rows, sdt Cols, class Real, int Options, class Alloc>
24 class Matrix : public MatrixBase<Matrix<Rows,Cols,Real,Options,Alloc>>
25 {
27 public:
29  Matrix() {}
31  Matrix(sdt rows, sdt cols) { this->resize(rows, cols); }
33  explicit Matrix(Real scalar) { this->fromScalar(scalar); }
35  Matrix(const Real* a, sdt rows, sdt cols, bool rowMajor = true) { this->resize(rows, cols); this->fromArray(a, rowMajor); }
37  Matrix(const Alloc& alloc) { this->setAllocator(alloc); }
39  template<class T>
40  Matrix(const MatrixBase<T>& rhs) { operator=(rhs); }
41 
43  template<class T>
44  Matrix& operator=(const MatrixBase<T>& rhs) { Super::operator=(rhs.subc()); return *this; }
45 };
46 
51 
52 }
MatrixS & fromScalar(Real f)
Initialize with scalar in every element.
Definition: Base.h:72
(m x n)-dimensional matrix
Definition: Matrix.h:24
Matrix(const Alloc &alloc)
Construct with allocator, for a dynamic matrix. Allocator element type must be int8.
Definition: Matrix.h:37
Matrix(const MatrixBase< T > &rhs)
Construct from matrix of any size. Asserts that any fixed dimensions in this matrix match those in rh...
Definition: Matrix.h:40
ptrdiff_t sdt
Size difference type, shorthand for ptrdiff_t.
Definition: Core.h:92
Matrix< matrix::dynamic, matrix::dynamic, Float > MatrixN_f
Definition: Matrix.h:49
Matrix< matrix::dynamic, matrix::dynamic, Double > MatrixN_d
Definition: Matrix.h:50
Matrix(Real scalar)
Initialize with scalar in every element.
Definition: Matrix.h:33
Matrix(const Real *a, sdt rows, sdt cols, bool rowMajor=true)
Initialize from array with dimensions (rows x cols). If the array is in row-major format set rowMajor...
Definition: Matrix.h:35
Definition: Traits.h:20
float Real
Real number type. See Real_ for real number operations and constants.
Definition: Real.h:21
MatrixS & resize(sdt rows, sdt cols)
Sets number of rows/columns and reallocates only if the size has changed (rows*cols). All previous data is lost on reallocation. Returns self.
Definition: Base.h:277
T * alloc(szt count=1)
Allocate memory for count number of T objects. Objects are not constructed.
Definition: Allocator.h:31
Matrix & operator=(const MatrixBase< T > &rhs)
Assign to matrix of any size. Asserts that any fixed dimensions in this matrix match those in rhs...
Definition: Matrix.h:44
Matrix(sdt rows, sdt cols)
Allocate elements for dimension sizes. Asserts that any fixed dimensions match rows / cols...
Definition: Matrix.h:31
Numeral< Real >::Real_ Real_
Operations and constants for Real type. See Float_, Double_.
Definition: Real.h:25
MatrixBase & operator=(const MatrixBase< T > &rhs)
Assign to matrix of any size. Asserts that any fixed dimensions in this matrix match those in rhs...
Definition: Base.h:97
Storage< Matrix< Rows, Cols, Real_, Options, Alloc_ > > Storage
Definition: Matrix.h:13
Matrix()
No init.
Definition: Matrix.h:29
Matrix base class.
Definition: Base.h:17
MatrixS & fromArray(const Num *a, bool rowMajor=true)
Initialize from array. If the array is in row-major format set rowMajor to true, otherwise set to fal...
Definition: Base.h:53
Global Honeycomb namespace.
Matrix< matrix::dynamic, matrix::dynamic > MatrixN
(m x n)-dimensional matrix types
Definition: Matrix.h:48